Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool How retrieve a remote webpage?

    Hi,

    I am using the below code, but I don't get retrieve the webpage in the screen:

    It is my code:



    <% Option Explicit %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> New Document </title>
    </head>

    <body>
    <form method=GET action="">
    <input type="text" name="strLink">
    <input type="submit" name="btnSubmit" value="Show">
    </form>

    <%
    Dim show
    if request.form("btnSubmit") = Show then
    Dim strPage ' holds the page
    Dim strDomain ' holds the domain
    Dim objXmlHttp ' XML Http object
    Dim strHTML ' holds the HTML code of the page
    Dim strTitleLength ' holds the length of the title
    Dim strBodyLength ' holds the length of the title
    Dim strTitle ' holds the title of the page
    Dim strStrip ' holds the parts between < >
    Dim strWarning ' holds a warning when the page seems to be invalid

    'enter the domain on which the page resides
    strDomain = request.form("strLink")


    ' XML routine to get the file
    Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
    objXmlHttp.open "GET", strDomain, False
    objXmlHttp.send
    strHTML = objXmlHttp.responseText
    Set objXmlHttp = Nothing

    strTitleLength = CInt(instr(lcase(strHTML),"</title>"))-CInt(instr(lcase(strHTML),"<title>")+7)
    strBodyLength = CInt(instr(lcase(strHTML),"</body>"))-CInt(instr(lcase(strHTML),"</head>")+7)

    ' determine whether the page has a valid title
    if CInt(instr(lcase(strHTML),"</title>")) = 0 or CInt(instr(lcase(strHTML),"<title>")+7) = 7 then
    strTitle = "No Title"
    else
    strTitle = Mid(strHTML,CInt(instr(lcase(strHTML),"<title>")+7),strTitleLength)
    end if

    ' determine whether the page has a valid body
    if CInt(instr(lcase(strHTML),"</body>")) = 0 or CInt(instr(lcase(strHTML),"</head>")+7) = 7 then
    strWarning = 1
    else
    strHTML = Mid(strHTML,CInt(instr(lcase(strHTML),"</head>")+7),strBodyLength)
    end if

    ' ******************** Do the actual stripping ********************
    do while CInt(instr(strHTML,"<")) > 0 and CInt(instr(strHTML,">") + 1) > CInt(instr(strHTML,"<"))
    strStrip = mid(strHTML,CInt(instr(strHTML,"<")),CInt(instr(strHTML,">") + 1)-CInt(instr(strHTML,"<")))
    strHTML = replace(strHTML,strStrip,"")
    loop
    strHTML = Replace(strHTML, vbCrLf, "")
    strHTML = replace(strHTML,"&nbsp;","")
    strHTML = replace(strHTML,"<br>","")
    Do While InStr(1, strHTML, " " ,vbTextCompare) > 0
    strHTML = Replace(strHTML , " ", " ")
    Loop
    ' ********************** The stripping ends **********************

    ' Give some output
    response.write("<font face=""Verdana"" size=""2"" color=""#0000CC"">Title:</font><br>")
    response.Write("<font face=""Verdana"" size=""2"" color=""#000000"">" & strTitle & "</font><br>")
    response.write("<font face=""Verdana"" size=""2"" color=""#0000CC"">Text Output:</font><br>")
    if strWarning = 1 then
    response.Write("<font face=""Verdana"" size=""2"" color=""#FF0000"">This seems to be an invalid HTML-file!</font><br>")
    end if
    response.Write("<font face=""Verdana"" size=""2"" color=""#000000"">" & strHTML & "</font><br>")
    end if
    %>

    </body>
    </html>
    I will be happy for any information.

    Thanks

    JLee

  • #2
    Regular Coder
    Join Date
    Sep 2004
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What's the error message you are getting? What url are you using?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •