Function to get Page Title from a URL

by Pete Freitag

I wrote a simple function today that grabs a url, and parses out the title of the page from the url:

<cffunction name="getPageTitle" returntype="string" output="false">
	<cfargument name="pageurl" type="string" required="true">
	<cfhttp method="get" redirect="true" url="#arguments.pageurl#" throwonerror="true"></cfhttp>
	<cfreturn ReReplace(cfhttp.fileContent, ".*<title>([^<>]*)</title>.*", "\1")>
</cffunction>

<cfoutput>#getPageTitle("http://www.macromedia.com/")#</cfoutput>

The Fixinator Code Security Scanner for ColdFusion & CFML is an easy to use security tool that every CF developer can use. It can also easily integrate into CI for automatic scanning on every commit.

Comments

Ryan Guill

nice. You ought to submit it to cflib.org

Ethan Cane

Hi there... Copied and pasted this code block. Have updated it to now return a complete anchor with href and title attributes. Works like a charm. Very inventive thinking. Will definitely come in handy at some point. Cheers

Mortgage Leads

Nice active blog you have. You have some great reading here.

Refinance Mortgage

Great blog.

Tom

I really enjoy reading your articles. Keep up the great work. TBoardenson

accountingapp.net

Domain for sale quality results found here

florida check advance

are you looking for check advance in florida check this site. check advance in florida can be found here to help you get through to payday.