I am writing an app that I want to read content from various web pages. I have done this in VB6 using an Internet Explorer control and the DOM model. Does anyone know if there is a better approach to this within .net?
It's pretty simple. The System.Net.WebClient types DownloadData method provides an easy way to get any data from a url:
Public Function GetWebPage(ByVal szURL As String) As String
Dim wc As New System.Net.WebClient()
Dim b() As Byte
Try
b = wc.DownloadData(szURL)
Catch ex As Exception
Return String.Format("Exception Occurred:{0}{1}", _
Environment.NewLine, ex.Message)
End Try
Return System.Text.Encoding.UTF8.GetString(b)
End Function
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.