Results 1 to 2 of 2

Thread: web page

  1. #1

    Thread Starter
    Lively Member johnrswanton's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    84

    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
    **********

  2. #2
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    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:
    1. Private Sub Command1_Click()
    2.     Text1.Text = SendXMLRequest("http://www.mywebsiteurl.com")
    3. End Sub
    4.  
    5. '// REFERENCE MS XML, Version 2.0
    6. Private Function SendXMLRequest(ByVal strUrl As String) As String
    7. On Error GoTo err:
    8.     Dim objHTTP As MSXML.XMLHTTPRequest
    9.     Set objHTTP = New MSXML.XMLHTTPRequest
    10.     objHTTP.Open "GET", strUrl, False
    11.     objHTTP.setRequestHeader "Content-Type", "text/html"
    12.     objHTTP.send: SendXMLRequest = objHTTP.responseText
    13.     If Len(SendXMLRequest) = 0 Or InStr(1, SendXMLRequest, _
    14.     "page not found", vbTextCompare) Then _
    15.     SendXMLRequest = "Page Not Found"
    16.     Exit Function
    17. err:
    18.     SendXMLRequest = "Error " & err.Number & _
    19.     vbCrLf & err.Description
    20.     Exit Function
    21. 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
  •  



Click Here to Expand Forum to Full Width