User Guide

Using the cfhttp Get Method 333
Reviewing the code
The following table describes the code and its function:
To get a Web page and save it in a file:
1 Open a new file in ColdFusion Studio.
2 Modify the file so that it appears as follows:
<cfhttp
method = "Get"
url="http://www.ci.newton.ma.us/main.htm"
path="c:\temp"
file="newtonmain.htm">
3 (Optional) Replace the url attribute value with the URL of a file you want to save
and change the filename.
4 (Optional) Change the path from C:\temp to a path on your hard drive.
5 Save the file as savewebpage.cfm and view it in a text editor. The file does not
display properly in your browser because the Get operation saves only the
specified Web page. 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.ci.newton.ma.us/
main.htm/
resolveurl="Yes">
Get the page specified in the URL and
make the links absolute instead of relative
so that they display 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.ci.newton.ma.us
/main.htm"
path="c:\temp"
file="newtonmain.htm">
Get the page specified in the URL and
save it in the file specified in
path and
file.
When you use the path and file
attributes, ColdFusion ignores any
resolveurl attribute. As a result, frames
and other included files cannot display
when you view the saved page.