Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract Meta Tags....

Status
Not open for further replies.

ClarkKent101

Programmer
Jul 19, 2006
48
DE
Hi Everyone,

I would just like to know - is it possible to extract the Meta Tag keywords/page title off of a webpage using Coldfusion?

I've been scouting the web looking for an example similar to what I want done to see if I could get pointed in the right direction but I've had no luck and so am beginning to wonder if it's even possible to do this. I know it's possible in PHP which has left me hoping it can be done in Coldfusion too :).

Thanks for your time,

- CK
 
there is no function that i can think of off the tp of my head, but it can be done.

You'd have to use cfhttp and then some string finding to do it. Something like this:

Code:
<cfhttp url="url you want to go to" method="get" />

<cfset metaKeyword = '<meta name="Keywords"'>
<cfset metaKeywordStart = FindNoCase(cfhttp.filecontent, metaKeyword)>

<cfset metaKeywordEnd = FindNoCase(cfhttp.filecontent, '>', metaKeywordStart)>

<cfoutput>
#Mid(cfhttp.filecontent, metaKeywordStart, (metakeywordEnd-metaKeywordStart))#
</cfoutput>

Something like that

Hope this helps!

Tony
 
Hi Tony,

Thanks a bunch! Perfect kickstart - only thing I changed in your code above is the parameter order in the FindNoCase() function...

Code:
<cfhttp url="url you want to go to" method="get" />

<cfset metaKeyword = '<meta name="Keywords"'>
<cfset metaKeywordStart = FindNoCase(metaKeyword, cfhttp.filecontent)>

<cfset metaKeywordEnd = FindNoCase('>', cfhttp.filecontent, metaKeywordStart)>

<cfoutput>
#Mid(cfhttp.filecontent, metaKeywordStart, (metakeywordEnd-metaKeywordStart))#
</cfoutput>

Thanks again,

- CK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top