User Guide

Table Of Contents
Using cfhttp to interact with the web 993
Reviewing the code
The following table describes the code and its function:
To get a web page and save it in a file:
1.
Create a ColdFusion page with the following content:
<html>
<head>
<title>Use Get Method</title>
</head>
<body>
<cfhttp
method = "Get"
url="http://www.macromedia.com/software"
path="c:\temp"
file="
macr_software.htm">
</body>
</html>
2.
(Optional) Replace the value of the url attribute with another URL and change the filename.
3.
(Optional) Change the path from C:\temp to a path on your hard drive.
4.
Save the page as save_webpage.cfm in the myapps directory under your web_root directory.
5.
Go to the specified path and view the file that you specified in a text editor (using the values
specified in step 1, this is C:\temp\macr_software.htm).
The saved file does not appear properly in your browser because the Get operation saves only
the specified web page HTML. It does not save the frame, image, or other files that the page
might include.
Reviewing the code
The following table describes the code and its function:
Code Description
<cfhttp method="Get"
url="http://www.macromedia.com"
resolveurl="Yes">
Get the page specified in the URL and make the links
absolute instead of relative so that they appear
properly.
<cfoutput>
#cfhttp.FileContent# <br>
</cfoutput>
Display the page, which is stored in the variable
cfhttp.fileContent, in the browser.
Code Description
<cfhttp
method = "Get"
url="http://www.macromedia.com/
software"
path="c:\temp"
file="macr_software.htm">
Get the page specified in the URL and save it in the file
specified by the
path and file attributes.
When you use the
path and file attributes,
ColdFusion ignores any
resolveurl attribute. As a
result, frames and other included files cannot appear
when you view the saved page.