eits Posted January 6, 2009 Share Posted January 6, 2009 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 :-). Quote Link to comment https://forums.phpfreaks.com/topic/139686-function-to-make-sure-blog-comments-page-is-nofollow/ Share on other sites More sharing options...
premiso Posted January 6, 2009 Share Posted January 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/139686-function-to-make-sure-blog-comments-page-is-nofollow/#findComment-730870 Share on other sites More sharing options...
eits Posted January 6, 2009 Author Share Posted January 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/139686-function-to-make-sure-blog-comments-page-is-nofollow/#findComment-730886 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.