Solved

SCREEN SCRAPE WITHIN SAME DOMAIN?

Posted on 2003-12-04
3
343 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unattended XML settings 4 103
API Soap Calls 4 91
Convert Oracle data into XML document 2 59
XML Data Missing in PHP SimpleXML 8 45
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now