我使用了一個批處理和Java腳本的組合,我發現使用批處理文件從網站中檢索html,而我們的一個地址沒有返回所需的輸出,因爲它在我使用url Firefox瀏覽器。腳本沒有正確地收到URL
我使用拉HTML的腳本是:
@if (@[email protected]) @then
@echo off
rem **** batch zone *********************************************************
setlocal enableextensions disabledelayedexpansion
rem Batch file will delegate all the work to the script engine
if not "%~1"=="" (
cscript //E:JScript "%~dpnx0" %1
)
rem End of batch area. Ensure batch ends execution before reaching
rem javascript zone
exit /b
@end
// **** Javascript zone *****************************************************
// Instantiate the needed component to make url queries
var http = WScript.CreateObject('MSXML2.ServerXMLHTTP.6.0');
// Retrieve the url parameter
var url = WScript.Arguments.Item(0)
// Make the request
http.open("GET", url, false);
http.send();
// If we get a OK from server (status 200), echo data to console
if (http.status === 200) WScript.StdOut.Write(http.responseText);
// All done. Exit
WScript.Quit(0);
我想喂腳本的URL是http://gatherer.wizards.com/Pages/Search/Default.aspx?output=spoiler&method=visual&action=advanced&set=[「阿拉伯+夜」]
或alternativly http://gatherer.wizards.com/Pages/Search/Default.aspx?output=spoiler&method=visual&action=advanced&set=[「一千零一夜」 ]
問題似乎是空間/ +爲沒有其它URL我餵它正在使用的空間或+
的WA Ÿ我打電話的腳本拉HTML是:
call callurl.cmd "http://gatherer.wizards.com/Pages/Search/Default.aspx?output=spoiler&method=visual&action=advanced&set=["Arabian+Nights"]"
編輯:找到原來的線程的腳本是從Open a URL without using a browser from a batch file
只改變我做了Msxml2.XMLHTTP.6.0改爲MSXML2.ServerXMLHTTP。 6.0因爲原始腳本由於我發現的安全性而無法加載網站。
謝謝你的幫助,但我仍然無法得到輸出我想HTML應列出一堆文本行,如
@ reddeath68,測試爲」geturl.cmd「http://gatherer.wizards.com/Pages/Search/Default.aspx?output=spoiler&method=visual&action = advanced&set = [「Arabian + Nights」]「'我得到了指示的輸出。你得到了什麼? –
http://pastebin.com/YRdJrsnS是我得到的輸出,它的值得注意的是,當添加到cmd行時,它將url添加爲「http://gatherer.wizards.com/Pages/Search/Default.aspx?outpu? ?t =擾流板&方法= vis ?? ual&動作=高級&??設置= [「阿拉伯+夜間??」]「 注意雙重問號 –