Problem using XMLHTTP Object to Get Url

Results 1 to 2 of 2

Thread: Problem using XMLHTTP Object to Get Url

  1. #1
    Join Date
    Dec 1969

    Default Problem using XMLHTTP Object to Get Url

    Hi,<BR><BR>I am attempting to get an URL using the XMLHTTP Object, after following the Instructions on the 4guysfromRolla Webtech section ( My problem is that the URL I would like to get automatically Redirects the User depending on the date, which results in the script looking on *my* Server for the page, rather than the Server that the page is actually located on. Basically, I need a modification to the script further below that will do the following:<BR><BR>If the URL that is used in the &#039;GET&#039; command is redirected to "foldername/filename.htm", there needs to be something added to the script so that instead of just looking for "foldername/filename.htm" (which causes it to look for it on *my* Server) it looks for it at "http://Url_Used_In_Get/foldername/filename.htm.<BR><BR>This is the code that I have been using:<BR><BR>&#060;%<BR>Response.Buffer = True<BR>Dim objXMLHTTP, xml<BR>Set xml = Server.CreateObject("Microsoft.XMLHTTP")<BR>xml.Op en "GET", "", False<BR>xml.Send <BR><BR>Response.Write xml.responseText<BR>Set xml = Nothing<BR>%&#062;<BR><BR>Thanks in advance for any help you can give!

  2. #2
    parsem Guest

    Default RE: Problem using XMLHTTP Object to Get Url

    What you mean to say is this:<BR>I grab an url using xmlhttp, and then when clicking on one of the hyperlinks, the url of the hyperlink is no longer correct, because the full url is not written in the file you grabbed.<BR>I had the same problem. <BR><BR>I solved it by doing the following:<BR><BR>1. Dim the returned strContents<BR>2. Use a regular expression to filter out the "broken"link.<BR>3. Return the strcontents+full urls<BR><BR><BR>Here&#039;s a sample of my code:<BR>What it does is:<BR><BR>1. grab content using xmlhttp<BR>2. get certain content from grabbed file(in between &#060;b&#062;and &#060;/b&#062;) using regular expressions, (these are the former hyperlinks which wouldn&#039;t work)<BR>3. Put the full url static in front of the returned &#060;b&#062;text that used to be an hyperlink&#060;/b&#062;<BR>4. I hope this makes sense to you... It&#039;s kinda hard to explain, <BR>otherwise just give a reply.<BR><BR><BR>&#060;% <BR>Set xml = Server.CreateObject("Microsoft.XMLHTTP") <BR>theQueryString="" <BR>xml.Open "GET", theQueryString, False <BR>xml.Send <BR><BR>strContents = xml.responseText<BR><BR>&#039;Create a regular expression object<BR>Dim objRegExp<BR>Set objRegExp = New RegExp<BR><BR>&#039;Set our pattern<BR>objRegExp.Pattern = "&#060;B&#062;(.*?)&#060;/B&#062;"<BR>objRegExp.IgnoreCase = True<BR>objRegExp.Global = True<BR><BR>&#039;Get the matches from the contents of our HTML file, strContents<BR>Dim objMatches<BR>Set objMatches = objRegExp.Execute(strContents)<BR><BR>Dim objMatch<BR>For Each objMatch in objMatches<BR> Response.Write "&#060;A href=;" & objMatch.Value & "&#060;/A&#062;" & "<BR>"<BR>Next<BR><BR><BR>Set objRegExp = Nothing &#039;Clean up!<BR>%&#062;<BR><BR><BR>(to think that I&#039;m only a rookie ...hahaha!)<BR><BR>Greetings Parsem.<BR>

Posting Permissions

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