HTTPGet(u)
Last updated November 11, 2002
Version: 1 | Requires: ColdFusion 5 | Library: NetLib
Description:
UDF equivelant of <CFHTTP>, pass it a URL and it'll return the stream. Does not support passing parameters or fields. Requires a complete URL with the protocol (the http://).
Return Values:
Returns a string.
Example:
<cfset page = HTMLEditFormat(page)>
Here is a portion of the HTML:
<p>
<cfloop index="x" from=1 to=5>
<cfset line = listGetAt(page,x,chr(10))>
<cfoutput>#line#<br></cfoutput>
</cfloop>
Parameters:
| Name | Description | Required |
|---|---|---|
| u | The URL to fetch. | Yes |
Full UDF Source:
<cfscript>
/**
* UDF equivelant of <CFHTTP>
*
* @param u The URL to fetch. (Required)
* @return Returns a string.
* @author Ben Forta (ben@forta.com)
* @version 1, November 11, 2002
*/
function HTTPGet(u) {
// Variables
var urlclass="";
var page="";
var stream="";
var c="";
var output="";
// Init class
urlclass=CreateObject("java", "java.net.URL");
// Get page
page=urlclass.init(u);
// Get stream
stream=page.getContent();
// Display it
for (c=stream.read(); c GT 0; c=stream.read())
{
output=output&chr(c);
}
// don't forget this part
stream.close();
return output;
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
10 day(s) ago
Will Belden added
longTime
15 day(s) ago
James Sleeman added
quickSort
25 day(s) ago
Ben Forta added
GetHostAddress
28 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)