Click here to Skip to main content
11,410,584 members (61,288 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
I have spent all day with little advise and no real progress to try and figure out a way to properly parse a http web request in vb.net.

I have read tutorials but most describe ways to use MSHTML which i find confusing.

This is the code I am using to return the HTML of a requested web page:

Dim input As String = TextBox1.Text
       Dim WebAddress As String = "https://www.google.com/" + input  
       ' Create a request for the URL.
       Dim request As WebRequest = _
         WebRequest.Create(WebAddress)
       ' If required by the server, set the credentials.
       request.Credentials = CredentialCache.DefaultCredentials
       ' Get the response.
       Dim response As WebResponse = request.GetResponse()
       ' Display the status.
       Label20.Text = (CType(response, HttpWebResponse).StatusDescription)
       ' Get the stream containing content returned by the server.
       Dim dataStream As Stream = response.GetResponseStream()
       ' Open the stream using a StreamReader for easy access.
       Dim reader As New StreamReader(dataStream)
       ' Read the content.
       Dim responseFromServer As String = reader.ReadToEnd()
       ' Display the content.
       Label2.Text = WebAddress
       RichTextBox1.Text = responseFromServer
       ' Clean up the streams and the response.
       reader.Close()
       response.Close()


As you can see The Richtextbox1 object is filled with the HTML output but I only wish to obtain and show specific portions of the HTML in given labels or textbox. Many people give the link and talk about the HTML Agility Pack but I have no idea how to pin point the areas of the HTML output in my Rich Textbox1 to do this.

Please if anyone can help with an example or a link that shows how to display selected HTML text from a textbox to a label or another textbox I will await your response.

Thank you in advance
Posted 5-Sep-12 18:17pm
Dale 20121.8K

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 8,885
1 OriginalGriff 6,915
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web04 | 2.8.150414.5 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100