Revision: 5480
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 11, 2008 13:36 by micmath
Initial Code
/**
* Get the contents returned from a web URL.
* @param {string} urlStr The web address of the page you wish to fetch.
* @returns {string} The contents of the web page.
*/
function fetch(urlStr) {
if (typeof java == "undefined") {
throw "This script requires java to run.";
}
else {
importPackage(java.io, java.net);
var url = new URL(urlStr);
var urlStream = url.openStream();
var reader = new BufferedReader(new InputStreamReader(urlStream, "latin1"));
var html = "";
var line;
while (line = reader.readLine()) {
if (line == null) break;
html += line;
}
return html;
}
}
Initial URL
Initial Description
Initial Title
Fetch the contents of webpage via Rhino
Initial Tags
Initial Language
JavaScript