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
Jose Diaz-Salcedo added
cfRssFeed
2 day(s) ago
Raymond Compton added
structBlend
23 day(s) ago
Duncan added
IsZIPUK
23 day(s) ago
Todd Sharp added
getTagContentAll
29 day(s) ago
Gerald Guido added
ListReturnDuplicat...
1 month(s) ago