transparent
Programmer
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("MSXML2.ServerXMLHTTP"
Then
'use version 3.0 of XMLHTTP
Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP"
Else
Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP"
End If
' Opens the connection to the remote server.
objXMLHTTP.Open "POST", strPathToCapture, False
' Actually Sends the request, posts the form details and returns the data:
objXMLHTTP.setRequestHeader "Content-Type","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 = " <body onload='javascript:document.form.submit();'>"
strCode = strCode & "<form name='form' method='post' action='" & strRedirectPath & "'>"
arrFormInputs = split(strItemstoPost,","
for i=0 to ubound(arrFormInputs)
arrFormPair = split(arrFormInputs(i),"="
strCode = strCode & "<input type='hidden' name='" & arrFormPair(0) & "' value=" & arrFormPair(1) & ">"
next
strCode = strCode & "</form></body>"
strWebPageScript = strCode & strWebPageScript
end if
Set objXMLHTTP = Nothing
'set up static file
Set objFSO = Server.CreateObject("Scripting.FileSystemObject"
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
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("MSXML2.ServerXMLHTTP"
'use version 3.0 of XMLHTTP
Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP"
Else
Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP"
End If
' Opens the connection to the remote server.
objXMLHTTP.Open "POST", strPathToCapture, False
' Actually Sends the request, posts the form details and returns the data:
objXMLHTTP.setRequestHeader "Content-Type","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 = " <body onload='javascript:document.form.submit();'>"
strCode = strCode & "<form name='form' method='post' action='" & strRedirectPath & "'>"
arrFormInputs = split(strItemstoPost,","
for i=0 to ubound(arrFormInputs)
arrFormPair = split(arrFormInputs(i),"="
strCode = strCode & "<input type='hidden' name='" & arrFormPair(0) & "' value=" & arrFormPair(1) & ">"
next
strCode = strCode & "</form></body>"
strWebPageScript = strCode & strWebPageScript
end if
Set objXMLHTTP = Nothing
'set up static file
Set objFSO = Server.CreateObject("Scripting.FileSystemObject"
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