Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grabbing an HTML page from another webserver

Status
Not open for further replies.

Rydel

Programmer
Feb 5, 2001
376
CZ
I've asked this question on ASP forum, but so far no one could answer it, and somebody told me to ask here. Although I think it's a bit off-topic here, I'll give it a shot:

"In VBScript/ASP how can I get an HTML page from another webserver and store it in a local ASP variable for further processing and analysis? E.g. the ASP script will be on while the page I will be grabbing will be somewhere on How can this be done? I've searched through this forum but could not find anything related..."

Thanks in advance!


regards,
rydel n23
 
Hello Rydel,

Try the following stripped down script. sURL can be data per client request. You do not need to save file, of course. The data stream responseBody before saving the where you can manipulate to your need.

'-----
Option Explicit

Const sPath = ".\"
Const sURL="Const sSavedFileName="329-626934.htm"

Dim sSavedFullFileName
sSavedFullFileName=sPath & sSavedFileName

WScript.echo "start downloading : "&sURL
GrabberEngine sSavedFullFileName, sURL
WScript.Echo "Download of " & sURL & " to " & sSavedFullFileName & " is complete."

Sub GrabberEngine(sFile, sURL)
const adTypeBinary = 1
const adModeReadWrite = 3
const adSaveCreateOverwrite = 2
'Error handle adding here particularly after oXML.send if no connection avail
'Without, let the script failed at runtime.
Dim oXML,oStream
set oXML = CreateObject("Microsoft.XMLHTTP")
oXML.open "GET", sURL, False
oXML.send
Set oStream=CreateObject("ADODB.Stream")
With oStream
.type = adTypeBinary
.mode = adModeReadWrite
.open
On Error Resume Next
Do
Wscript.Sleep 250
.write oXML.responseBody
Loop Until Err.number = 0
On Error Goto 0
.savetofile sFile, adSaveCreateOverwrite
End With
Set oStream=Nothing
End Sub
'-----

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top