Skip to content

Instantly share code, notes, and snippets.

@yukioc
Created February 12, 2011 15:36
Show Gist options
  • Save yukioc/823826 to your computer and use it in GitHub Desktop.
Save yukioc/823826 to your computer and use it in GitHub Desktop.
simple JScript web file viewer like a wget.
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