Ever wanted to view the source code of another page or site using coldfusion? Well, you won't believe how simple it can be.

We will be using 1 tag and 1 function to accomplish this.

<!--- Set the URL of the page's source you want to view --->
<cfhttp method="get" url="http://www.google.com"></cfhttp>

<!--- Then we display the view source code by doing this: --->
#htmleditformat(cfhttp.filecontent)#

That's all there is! That will display the source code of any URL on the web, this is how it all looks together:

<cfoutput>
    <cfhttp method="get" url="http://www.google.com"></cfhttp>
    #htmleditformat(cfhttp.filecontent)#
</cfoutput>

Have Fun!

About This Tutorial
Author: Matt Wegrzyn
Skill Level: Beginner 
 
 
 
Platforms Tested: CFMX
Total Views: 96,547
Submission Date: January 28, 2005
Last Update Date: June 05, 2009
All Tutorials By This Autor: 2
Discuss This Tutorial
  • There is no way to actually fullly encode an html page as far as I know. Also, the code in this tutorial can be made clearer, by using htmlcodeformat, instead of htmleditformat. When I wrote this tutorial, I didn't have as much cf knowledge. You may wish to display the http headers using cfhttp.header code as well: #htmlcodeformat(cfhttp.header)#

    #htmlcodeformat(cfhttp.filecontent)#

  • Sir, Great One, but have any Other method to encode page so nobody can view it

Advertisement

Sponsored By...
Deep Tissue Massage and Swedish Massage Services just $39 for a 50 minute massage!