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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Index server, Microsoft.XMLHTTP and FSO

Status
Not open for further replies.

transparent

Programmer
Sep 15, 2001
333
GB
I am attempting to solve the problem of index servers inability to index dynamic pages, I have written a script which should generate static pages from the asp source. I do this by passing the required form data to the asp page using the Microsoft.XMLHTTP object, and writing the response to a text file, for indexing.

However asp pages which generate lots of information (stored in strWebPageScript ) result in empty text files! Small target asp pages seem fine.

Does anybody have any idea why this is happening?

Cheers


<%
Sub DoStaticVersion(ByVal strWhereToSave, ByVal strPathToCapture, ByVal strRedirectPath, ByVal strItemstoPost)


On Error Resume Next ' Switch off error handling


' ---- description: rips a webpage from a given address and stores it to a
' named location on the local web server. Used for indexing -
' a redirect url is inserted into a ripped page to the correct
' dynamic page

' ---- inputs: strWhereToSave - the physical path (including textfile name) to store ripped page
' strPathToCapture - the web address of the page to rip
' strRedirectPath - relative path from created file to dynamic equivilant
' strItemstoPost - form information to pass

' ---- notes: works with both static and dynamic pages, e.g ripping
' news_listings.asp?id=3 would create a static version
' of that generated page...

Dim objXMLHTTP 'XMLHTTP object
Dim strWebPageScript 'captured webpage script
Dim strRedirect 'where to redirect to (what REAL dynamic page)

Dim strCode, arrFormValues, arrFormInputs, arrFormPair

Dim objFSO 'FSO Object
Dim objNewFile

' Create an xmlhttp object:
If IsObject(&quot;MSXML2.ServerXMLHTTP&quot;) Then
'use version 3.0 of XMLHTTP
Set objXMLHTTP = Server.CreateObject(&quot;MSXML2.ServerXMLHTTP&quot;)
Else
Set objXMLHTTP = Server.CreateObject(&quot;Microsoft.XMLHTTP&quot;)
End If

' Opens the connection to the remote server.
objXMLHTTP.Open &quot;POST&quot;, strPathToCapture, False
' Actually Sends the request, posts the form details and returns the data:
objXMLHTTP.setRequestHeader &quot;Content-Type&quot;,&quot;application/x- objXMLHTTP.Send strItemstoPost
'save the resultant HTML in a string
strWebPageScript = objXMLHTTP.responseText
'destroy object


'insert the redirect script line

if strRedirectPath <> Empty then
strCode = &quot; <body onload='javascript:document.form.submit();'>&quot;
strCode = strCode & &quot;<form name='form' method='post' action='&quot; & strRedirectPath & &quot;'>&quot;
arrFormInputs = split(strItemstoPost,&quot;,&quot;)
for i=0 to ubound(arrFormInputs)
arrFormPair = split(arrFormInputs(i),&quot;=&quot;)
strCode = strCode & &quot;<input type='hidden' name='&quot; & arrFormPair(0) & &quot;' value=&quot; & arrFormPair(1) & &quot;>&quot;
next
strCode = strCode & &quot;</form></body>&quot;
strWebPageScript = strCode & strWebPageScript
end if

Set objXMLHTTP = Nothing

'set up static file
Set objFSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objNewFile = objFSO.CreateTextFile(strWhereToSave, true)
objNewFile.Write(strWebPageScript)
'destroy FSO objects
objNewFile.Close
Set objNewFile = Nothing
Set objFSO = Nothing
on error goto 0
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top