|
-
Aug 3rd, 2006, 06:27 PM
#1
Thread Starter
Lively Member
web page
i was just wondering if it is posible to read the source code of a web page in visual basic i know its posible n asp cause ive tried it n it worked but is there any way of converting it into vb the code for asp is shown below
<%
Response.Buffer = True
Dim objXMLHTTP, xml
' Create an xmlhttp object:
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
' Opens the connection to the remote server.
xml.Open "GET","http://www.mywebpage.htm", False
' Actually Sends the request and returns the data:
xml.Send
'Display the HTML both as HTML and as text
Response.Write "<h1>The HTML text</h1><xmp>"
response.Write xml.responseText
Response.Write "</xmp>"
Set xml = Nothing
%>
thanx
*********** "why do things that are suspose to bad for us taste so good, whats ur addiction"
Kanye West **********
-
Aug 3rd, 2006, 07:01 PM
#2
PowerPoster
Re: web page
There are examples in my sig under 6WaysToGetHtml ..
Also there is Winsock which doesnt freeze the app while it connects to the URL but that is more complicated.
VB Code:
Private Sub Command1_Click()
Text1.Text = SendXMLRequest("http://www.mywebsiteurl.com")
End Sub
'// REFERENCE MS XML, Version 2.0
Private Function SendXMLRequest(ByVal strUrl As String) As String
On Error GoTo err:
Dim objHTTP As MSXML.XMLHTTPRequest
Set objHTTP = New MSXML.XMLHTTPRequest
objHTTP.Open "GET", strUrl, False
objHTTP.setRequestHeader "Content-Type", "text/html"
objHTTP.send: SendXMLRequest = objHTTP.responseText
If Len(SendXMLRequest) = 0 Or InStr(1, SendXMLRequest, _
"page not found", vbTextCompare) Then _
SendXMLRequest = "Page Not Found"
Exit Function
err:
SendXMLRequest = "Error " & err.Number & _
vbCrLf & err.Description
Exit Function
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|