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

how to check if the link exist in the remote website

Guest
Sep 25, 2008 Sep 25, 2008
Hi all:

Can you guys please tell me if there is a way I can check if the link exist in the remote website? for example

<cfif hyper link to www.mysite.com exisit in www.remotesite.com>
good .. let's continue
<cfelse>
Please add link to www.mysite.com before you can continue
</cfif>

Is this possible ... do you have to use spider? If so how do I do it?

Thanks Guys,
A
TOPICS
Getting started
2.9K
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

correct answers 1 Correct answer

LEGEND , Oct 02, 2008 Oct 02, 2008
to expand on tclaremont's excellent suggestion:

you can use refindnocase() to search the filecontent returned by cfhttp
call:

<cfset myurl = " http://www.yourwebsite.com">
<cfhttp url=" http://www.VisitorsPage" method="GET" result="Foobar"
resolveurl="yes" getasbinary="auto"></cfhttp>
<cfif
foobar.Statuscode is "200 OK">
<cfif refindnocase('<a [^>]*href[^>]*' & replace(myurl, '.', '\.',
'all') & '[^>]*>(.*?)<\/a>', Foobar.filecontent)>
link exists
<cfelse>
no link...
</cfif>
<cfelse>
con...
Translate
Advocate ,
Sep 25, 2008 Sep 25, 2008
Hi,

Try implementing "Google's Site Search API" in your application, You can find more information on this API at,

http://www.fiftyfoureleven.com/weblog/web-development/programming-and-scripts/apis/google-search-api

HTH
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
Advocate ,
Sep 25, 2008 Sep 25, 2008
Also,

You can have a demo at,

http://www.google.com/sitesearch/
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 ,
Sep 29, 2008 Sep 29, 2008
You can peform a CFHTTP call to the link they inputted, and then evaluate the results of that call. If the response is greater than a certain size, there is a pretty good chance that the URL is valid. If it is tiny, it is probably returning a file not found type of message.

You could also show the content of the link in a frame or new window, and ask the end user to verify with a Y/N box that this is, in fact, the page they want to use.
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
Guest
Sep 30, 2008 Sep 30, 2008
hi guys sitesearch is not free so that's not going to work for me as this is a non profit community site. tclaremont can you post some code example of your approach with cfhttp?

Thank you all of you..

A
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 01, 2008 Oct 01, 2008
Sorry, but I seem to have confused your question with another on the forums, and suggested an answer that is not exactly what you were looking for.

If I understand corectly, you are looking to see if a URL exists on ANOTHER website? What is your objective 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
Engaged ,
Oct 01, 2008 Oct 01, 2008
OK, after thinking about your post some more, it sounds like you are trying to determine if another site contains a link back to your site, probably so you can establish reciprocal links or something like that.

You can start by asking the visitor to enter the URL of the page where your link is supposed to appear. Lets say they enter " http://www.VisitorsPage.htm".

You would then need to do a CFHTTP of that page, like this:

<cfhttp url=" http://www.VisitorsPage" method="GET" result="Foobar" resolveurl="yes" getasbinary="auto"></CFHTTP>

This will return a number of variables, one of them being FileContent, which is, predictably, the content.

#Foobar.FileContent#

Then, use ColdFusions string functions to SEARCH the retrieved page (#Foobar.FileContent#) for instances of your URL. If the function returns at least one match, you know that the link in question exists on that page.
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
LEGEND ,
Oct 02, 2008 Oct 02, 2008
to expand on tclaremont's excellent suggestion:

you can use refindnocase() to search the filecontent returned by cfhttp
call:

<cfset myurl = " http://www.yourwebsite.com">
<cfhttp url=" http://www.VisitorsPage" method="GET" result="Foobar"
resolveurl="yes" getasbinary="auto"></cfhttp>
<cfif
foobar.Statuscode is "200 OK">
<cfif refindnocase('<a [^>]*href[^>]*' & replace(myurl, '.', '\.',
'all') & '[^>]*>(.*?)<\/a>', Foobar.filecontent)>
link exists
<cfelse>
no link...
</cfif>
<cfelse>
connection error... or requested web page does not exist...
</cfif>

of course, if the www.VisitorsPage site is sneaky and has the link to
your site in page's code, but hides it with css/javascript, it's gonna
be tricky to uncover using regexp... better just go and look at their
website...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
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
Guest
Oct 03, 2008 Oct 03, 2008
LATEST
Thank you to both of you tclaremont and Azadi. You guys Rocks!!!

A
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