Hi guys,
I have a fairly simple question reguarding connecting to the internet in a VB app.
I was just wondering how i might go about getting the HTML from a website using the URL in VB.net.
For instance, in perl you might just say
my @data = get(http://www.google.com/);
How can i do this in VB
Thanks in advance
-Robert

Getting HTML from a website
gyurisc
Imports
system.netImports
System.IOPublic
Class frmgetHTTP Private Function getHTTP(ByVal url As String) Dim httpRequest As HttpWebRequest Dim httpResponse As HttpWebResponse Dim bodytext As String = "" Dim responseStream As Stream Dim bytes As Int32 Dim RecvBytes(Byte.MaxValue) As BytehttpRequest =
CType(WebRequest.Create(url), HttpWebRequest)httpResponse =
CType(httpRequest.GetResponse, HttpWebResponse)responseStream = httpResponse.GetResponseStream()
Do While (True)bytes = responseStream.Read(RecvBytes, 0, RecvBytes.Length)
If bytes <= 0 Then Exit Dobodytext += System.Text.Encoding.UTF8.GetString(RecvBytes, 0, bytes)
Loop Return bodytext End FunctionRoland H
hi,
if you want the html as text you can use Webclient
this is the same question
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=404782&SiteID=1
hope this helps
windyweather
One way of doing it may be. download the HTML file to a file and then read this file
My.Computer.Network.DownloadFile(<URL>, <Filename>)
Dim s as string = My.COmputer.FileSystem.ReadAllText (<Filename>)
Not the most efficient but it should work.
OlyJim
SP Steve
Another way to do it is like this:
Protected Friend with events wb as new webBrowser
Private sub Load_(blah as blah,blah as blah)
end sub
Private sub wb_DocumentComplete (blah as blah,blah as blah) Handles DocumentComplete
end sub