Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web page reading in .net

Status
Not open for further replies.

MarkRuse

Programmer
Aug 11, 1999
29
GB
Hi,

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?

Thanks

Mark Ruse
 
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

Hope this helps,

Si
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top