Function to get Page Title from a URL
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>
Like this? Follow me ↯Tweet Follow @pfreitag
Function to get Page Title from a URL was first published on March 23, 2005.
If you like reading about cfml, or regex then you might also like:
- CFParam for Integer or Empty String
- Auto-Linking Comments
- Regex to Replace Multiple Blank Lines with One
- REFind and ReReplace support \r \n and \t
- Regular Expressions with ColdFusion - a Howto Guide
The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.