Solved

SCREEN SCRAPE WITHIN SAME DOMAIN?

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

11 Experts available now in Live!

Get 1:1 Help Now