Solved

SCREEN SCRAPE WITHIN SAME DOMAIN?

Posted on 2003-12-04
3
348 Views
Last Modified: 2010-05-18
Hi experts,

I am trying to use the Microsoft.XMLHTTP object in asp to screen scrape a page with my domain from another page within my domain.

It doesn't seem to work although if I scrape a page from another doamin it works fine. Do any of you know if it is impossible to use this object in order to scrape a page from within the same domain or does my code need modification.

Any comments would be appreciated.


My code is as follows:

Dim objXML

Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
strURL ="testPage.asp"
objXML.Open "GET" , strURL , False ,"",""
objXML.Send

If Err.Number = 0 Then                  'no errors
If objXML.Status = 200 then            'url is valid
strOpen = objXML.ResponseText

response.write(strOpen)

Else
Response.Write "Incorrect URL"
End if
Else
Response.Write Err.Description
End If

Set objXML = Nothing





PJORDANNA
0
Comment
Question by:pjordanna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:pjordanna
ID: 9876073
I've also tried it with an absolute URL.


PJORDANNA
0
 
LVL 26

Accepted Solution

by:
rdcpro earned 500 total points
ID: 9878194
This is the old XMLHTTPRequest object from the old version 2 parser.  Don't use it on the server!  This is very important, since the old version was not server-safe.  Use instead:

Set objXML = Server.CreateObject("Msxml2.ServerXMLHTTP")


It has to be an absolute URL...this code works on my machine:

<%@ Language=VBScript %>
<%

Dim objXML

Set objXML = Server.CreateObject("Msxml2.ServerXMLHTTP")
strURL ="http://localhost/sandbox/default.htm"

objXML.Open "GET", strURL , false

objXML.Send

If Err.Number = 0 Then               'no errors
If objXML.Status = 200 then          'url is valid
strOpen = objXML.ResponseText

response.write(strOpen)

Else
Response.Write "Incorrect URL"
End if
Else
Response.Write Err.Description
End If

Set objXML = Nothing

%>


Regards,
Mike Sharp

0
 

Author Comment

by:pjordanna
ID: 9880813
Hi Mike,

I actually got it working last night but thanks for the info about the new version of XMLHTTP. I have implemented this new version as a replacement.





PJORDANNA
0

Featured Post

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question