Created
February 12, 2011 15:36
-
-
Save yukioc/823826 to your computer and use it in GitHub Desktop.
simple JScript web file viewer like a wget.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function alert(s){ WScript.StdOut.Write(s||""); } | |
function print(s){ WScript.StdOut.Write(s||""); } | |
function sleep(t){ WScript.Sleep(t); } | |
function exit(){ WScript.Quit(); } | |
function url_get(url){ | |
var xh=new ActiveXObject("Microsoft.XMLHTTP"); | |
var s=undefined; | |
xh.open("get",url,true); | |
xh.onreadystatechange = function(){ | |
if(xh.readyState == 4){ | |
if(xh.status == 200){ | |
s = xh.getAllResponseHeaders(); | |
s += xh.responseText; | |
}else{ | |
s = "err:"+xh.status; | |
} | |
} | |
} | |
xh.send(); | |
while(!s){ sleep(1000); } | |
return s; | |
} | |
var args=WScript.Arguments; | |
if (args.length == 0){ | |
print("Usage: cscript urlget.js <url>"); | |
exit(); | |
} | |
var url=args(0); | |
var s=url_get(url); | |
print(s); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment