Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

getting link info

Explorer ,
Oct 07, 2008 Oct 07, 2008
I am trying to do something similar to facebook's share
link application where a link name is posted and it
automatically extracts the meta description information
of that website page. or if no description is provided
it extracts the title.

I tried using cfhttp tag but i think my approch is
somewhat wrong/ can anybody Guide me how i can achiever
this Result. I shall very be great if You Please
provide the exactly how can i do it.

Invoking a webservice is the second option but that
also is somewhat tricky

Hope guys/experts will help me here sort out the
problem

Cheers

TOPICS
Getting started
300
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 07, 2008 Oct 07, 2008
Use CFHTTP and get the page content of the URL that the end user has entered. Then use the CF string functions to extract the content that appears between the meta tags of CFHTTP.FileContent.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 08, 2008 Oct 08, 2008
I tried it something like this:

<cftry>
<cfhttp url="#trim(form.sharelink)#" method="get" throwonerror="false" timeout="5">
<cfset MetaStartIndex = findNoCase('<meta http-equiv="description" content=', cfhttp.FileContent)>
<cfset MetaEndIndex = findNoCase('/>', cfhttp.FileContent, MetaStartIndex)>
<cfset Metant = mid(cfhttp.FileContent,MetaStartIndex,MetaEndIndex-MetaStartIndex+1)>
<cfcatch type="any">
<cfset err = 1>
</cfcatch>
</cftry>
</cfif>
<cfdump var="#Metant#">


and due to some cause i am getting this alue:

<meta http-equiv="description" content="The website about my webportal and forums and shop area and jobs system" /> <scr

as my result

i think i am skipping something here
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 09, 2008 Oct 09, 2008
hi, running cool but it sometimes show error:

the code i am running is:

<cftry>
<cfhttp url="#trim(form.sharelink)#" method="get" throwonerror="no" timeout="5"></cfhttp>
<cfset MetaContentStartIndex = findNoCase('<title>', cfhttp.FileContent)>
<cfset MetaContentEndIndex = findNoCase('</title>', cfhttp.FileContent, MetaContentStartIndex)>
<cfset MetaAmount = mid(cfhttp.FileContent,MetaContentStartIndex,MetaContentEndIndex-MetaContentStartIndex+8)>
<cfset results = "#Replace(MetaAmount,'<title>',','All')#">
<cfset mainresult = "#Replace(results,'</title>',','All')#">
<cfcatch type="any">
<cfset err = 1>
</cfcatch>
</cftry>

and sometime i recieve the below type error:

The 2 parameter of the Mid function, which is now 0, must be a non-negative integer
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 09, 2008 Oct 09, 2008
LATEST
I think that means it did not find your start string and/or your end string.

There is no rule that forces web sites to make use of the HTML tags in question. They flat out might not be there.

To circumvent this, use error handling in CF.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources