Fetching a Web Page

From C3 Wiki

Jump to: navigation, search

[edit] Summary

This script will fetch a URL and return the response text, usually HTML of the page.

A nifty example of using this method would be to call it on a bulk import. Say you are importing Adverse Events (AEs) from an old system and would like to have an HTML snapshot of what the AE looked like at the time of the import. Add a few lines of code to the postImportHandler to generate a URL pointing to the AE in the old system. Call this method to fetch a printer version. Save the results into a document and attach it to the imported AE.


CustomUtils.getWebPage a per type JScript

function getWebPage(URL)
{
	//Retrieve the web page specified in the URL parm.
	try {
		var html = ""
		var xml=new ActiveXObject("Microsoft.XMLHTTP");
		xml.open("GET",URL,false);
		xml.send();
		html = xml.responseText + "\n";
		xml = null;
		return html;
	}
	catch (e) {
		wom.log("EXCEPTION CustomUtils.getWebPage: " + e.description);
		wom.log("EXCEPTION CustomUtils.getWebPage: URL=" + URL);
		throw(e);
	}
}



Washington University in Saint Louis