javascript - 批处理 - 启动 Internet Explorer 并将网站内容保存到 Sript/variable/array

标签 javascript batch-file csv browser

我知道可以在特定网站上批量启动网络浏览器 - 但我想保存已查看网站的内容。

它将是该浏览器中查询脚本的结果集,结果如下所示:

header2;header2;header3

result1;result2;result3

所以基本上就像一个 CSV。

我知道如何打开浏览器,但我不知道其他部分是否可以。

最佳答案

将其另存为 .bat ( it's a .bat/.vbs hybrid ) 并替换为您的地址/输出文件:

: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

关于javascript - 批处理 - 启动 Internet Explorer 并将网站内容保存到 Sript/variable/array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21090828/

相关文章:

windows - 使用 sc.exe 使用当前用户帐户创建 Windows 服务

csv - hadoop如何读取输入文件?

python - 使用 Pandas 在 Python 中读取大块的 csv 文件

javascript - Webextension Firefox 警报未触发

javascript - 从 JSON 格式的 'description' 动态定义 Mongoose 模式

javascript - jQuery 创作和关闭

javascript - "deferred"脚本加载并执行后如何执行代码?

windows - 批处理文件以在 Windows 中运行其他批处理文件

Windows 7 从命令行清空整个目录

python - 值错误 : time data '' does not match format '%d-%m-%Y %H:%M:%S'