Jump to content

Recommended Posts

Hi,

 

I am using CURL to rip a webpage into $html. I now need to know if this page contains the nofollow tag - could anybody please explain a way of how I could do this?

 

I did try:

if(!strstr($html,'nofollow')) { 
		return "follow"; }
			  
			  
else { return "nofollow"; }				 

 

....but it doesn't seem to work too well and seems a bit 'hacky'. Has anybody got a better way? I thought I may just add I am trying to prevent spam not create it :-).

if(stristr($html,'nofollow') !== false) {
         return "follow"; } 
else { return "nofollow"; }  

 

Also check that it is nofollow and not no,follow or no-follow etc. But that should work. The !== operator checks that it is truly false, since 0 can be interpreted as a false, this makes sure it is just not at the start of a string.

 

As for bots obeying the nofollow rule, that does not apply to spam bots. They choose to ignore it. That only applies to bots that index your site for search engines really.

if(stristr($html,'nofollow') !== false) {
         return "follow"; } 
else { return "nofollow"; }  

 

Unfortunately this is being too stringent and seems to always return false. Am I missing something simple? - And thanks for the quick response.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.