By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,558 Members | 1,699 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,558 IT Pros & Developers. It's quick & easy.

How to grab html code from remote website?

P: n/a
How to grab html code from remote website?
can someone help?
please let me know...
vjay

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Here's a function I wrote for what you're asking, if I understand you.
For this to work you need Imports System.Net and Imports System.IO.

Public Function GetSource(ByVal URL As String) As String

Dim vSource As String = ""
Dim HTTPRequest As HttpWebRequest
Dim vURL As Uri
Dim sr As StreamReader
Dim Ln As String
Dim rs As HttpWebResponse
Dim inStr As Stream
Dim line As String
Dim bodyReader As StreamReader

vURL = New Uri(URL)
HTTPRequest = WebRequest.Create(URL)
HTTPRequest.AllowAutoRedirect = True
HTTPRequest.MaximumAutomaticRedirections = 10
HTTPRequest.Method = "GET"
HTTPRequest.ProtocolVersion = New Version(1, 0)
HTTPRequest.Timeout = New TimeSpan(0, 0, 30).TotalMilliseconds
HTTPRequest.UserAgent = "Mozilla/3.0 (compatible; Enigmatic/1.0)"

rs = HTTPRequest.GetResponse()
vURL = rs.ResponseUri
inStr = rs.GetResponseStream()

If Not (inStr) Is Nothing Then
bodyReader = New StreamReader(inStr)
line = bodyReader.ReadLine()
Do While (line) Is Nothing = False
vSource &= line & vbCrLf
line = bodyReader.ReadLine()
Loop
bodyReader.Close()
bodyReader = Nothing
End If

rs.Close()
rs = Nothing
HTTPRequest = Nothing
Return vSource

End Function

Vjay77 wrote:
How to grab html code from remote website?
can someone help?
please let me know...
vjay


--

Confucious say: "He who stands on toilet is high on pot."
Nov 21 '05 #2

P: n/a
Excellent,Thanks a lot for your time.
VJAY

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.