Groups | Blog | Home
all groups > vb.net upgrade > december 2004 >

vb.net upgrade : download html in .net 2003 and 2005?


aaron_kempf NO[at]SPAM hotmail.com
12/22/2004 3:38:55 PM
i'm having some problems getting ServerHttpXml to work in .net.. I would
like to examine the alternatives to this in VS2003 and VS2005.

All i want to be able to do is to pass thru my proxy server and download
html (based on a url)

I would rather filter out certain characters as early as possible; if you
knwo what i mean.


Ken Tucker [MVP]
12/27/2004 10:33:02 PM
Hi,

Screen Scraping
Add the following imports to top of file.
Imports System.Text

Imports System.Net


Sample code
'STEP 1: Create a WebClient instance

Dim wc As New WebClient



'STEP 2: Call the DownloadedData method

Const strURL As String = "http://msdn.microsoft.com/"

Dim aRequestedHTML() As Byte

aRequestedHTML = wc.DownloadData(strURL)

'STEP 3: Convert the Byte array into a String

Dim objUTF8 As New UTF8Encoding

Dim strRequestedHTML As String

strRequestedHTML = objUTF8.GetString(aRequestedHTML)

'step 4 save to html file

Dim fs As New System.IO.StreamWriter("C:\MSDNWebPage.html")

fs.WriteLine(strRequestedHTML)

fs.Close()

' step 5 display data

Process.Start("C:\msdnwebpage.html")



http://www.4guysfromrolla.com/webtech/070601-1.shtml

Ken

-----------------------



[quoted text, click to view]
AddThis Social Bookmark Button