Solved

SCREEN SCRAPE WITHIN SAME DOMAIN?

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
json format text only 4 102
Cannot open file from ASP if user is "logged in" 13 35
Powershell import xml to array (non-cli xml) 4 36
xml with php question 5 37
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…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

696 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