Reputation: 47
I know that it's possible to launch a web browser on a specific website with batch - but I want to save the content of the viewed website.
It will be a result set of a query script inside of this browser, and the result will look like:
header2;header2;header3
result1;result2;result3
So basically like a CSV.
I know how to open a browser, but I don't know if the other part is possible.
Upvotes: 1
Views: 866
Reputation: 57252
save this as .bat (it's a .bat/.vbs hybrid) and replace with your address/output file:
:sub echo(str) :end sub
echo off
'>nul 2>&1|| copy /Y %windir%\System32\doskey.exe '.exe >nul
'& rem cscript /nologo /E:vbscript %~f0 "%~1" > "%~2"
'& cscript /nologo /E:vbscript %~f0 "http://www.google.bg/" >google.txt
'& pause
'& rem "'.exe"
'& exit /b
'You must turn-off certificate mismtatch warnings"
'internet explorer -> tools -> options -> advanced tab -> uncheck certificates mismatch
'you must also disable ActiveX prompting:
'internet explorer -> tools -> options -> security -> custom level -> automatic prompt for activeX: disabled
URLToExtract=WScript.Arguments.Item(0)
SaveToFile=""
'prepare objects
Dim objIE, strAllText
Set objIE = CreateObject( "InternetExplorer.Application" )
objIE.Visible = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
'extract document data function
Sub URLExtract(strURL,objIE,strAllText,strFilePath,objFSO)
'WScript.echo strFilePath
Dim blnTimedOut, i
objIE.Navigate2 strURL
Do While objIE.Busy
WScript.Sleep 150
i = i + 1
' Time out after 10 seconds
If i > 100 Then
blnTimedOut = True
Exit Do
End If
Loop
If Not blnTimedOut Then strAllText = objIE.Document.Body.InnerText
'If Not blnTimedOut Then Wscript.echo objIE.Document.Body.outerHTML
'If Not blnTimedOut Then Wscript.echo objIE.Document.Body.innerHTML
'strAllText=Escape(strAllText)
'Set Writer = objFSO.OpenTextFile(strFilePath, 2,true,0)
WScript.Echo strAllText
'Writer.WriteLine(strAllText)
'Writer.Close
end SUB
Call URLExtract(URLToExtract,objIE,strAllText,SaveToFile,objFSO)
objIE.Quit
Upvotes: 2