Function to get Page Title from a URL

coldfusion

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>


Related Entries

13 people found this page useful, what do you think?

 Download FuseGuard WAF for ColdFusion

Trackbacks

Trackback Address: 285/4A1FF4AB5F55AA138D99E3C4E0B93205

Comments

On 03/23/2005 at 9:33:01 PM EST Ryan Guill wrote:
1
nice. You ought to submit it to cflib.org

On 03/23/2005 at 10:33:30 PM EST David wrote:
2

ReReplaceNoCase

On 03/23/2005 at 10:35:58 PM EST David wrote:
3
Oops, a bit too quick with the old post button! That should have said:

Cheers Ryan,

How about using a ReReplaceNoCase it allow for HTML like: <TITLE>My Site</TITLE>?

cheers

David

On 03/27/2005 at 5:26:11 PM EST Ethan Cane wrote:
4
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

On 08/17/2005 at 3:09:35 AM EDT jaded wrote:
5
hi,

will this work using php? =)

On 01/27/2006 at 5:32:28 PM EST Terrence Ryan wrote:
6
Thanks for sharing this. I wanted to do the same thing today, but I'm not so great with the regular expressions.

On 02/11/2006 at 5:30:36 AM EST Mortgage Leads wrote:
7
Nice active blog you have. You have some great reading here.

On 02/13/2006 at 12:14:35 AM EST Refinance Mortgage wrote:
8
Great blog.

On 03/06/2006 at 8:29:23 PM EST Tom wrote:
9
I really enjoy reading your articles. Keep up the great work. TBoardenson

On 06/29/2006 at 3:46:26 AM EDT accountingapp.net wrote:
10
Domain for sale quality results found here

On 06/30/2006 at 6:57:35 PM EDT florida check advance wrote:
11
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.

On 06/23/2007 at 7:02:40 AM EDT iknowall wrote:
12
Not secret that that that we search for, whereas you will not always find on the first page of search engine. But in other, although it rarely or in no way you use, this in sight. Therefore you will focus attention on http://www.iknowall.com. It searches for simultaneously in three largest bases of peace and issues results at will - on one page or on the different. Parsit'. is probable, also possible simultaneously all.

http://www.iknowall.com

Post a Comment




  



Spell Checker by Foundeo

Recent Entries



foundeo


did you hack my cf?