Here's what I need - to provide a URL and a chunk of HTML to a function, and have it return a boolean if it finds the HTML on the specific page. So: checklinks($url, $html) Where: $url = "http://www.example.com/pagexyz.html"; $html = "<a href=\"http://www.example.com\">Example Link</a> - This is sample description text to go with my link."; Basically I'm building a script to check if people are keeping their reciprocal links to my sites. I appreciate the help
use the file() function to suck the page into a var. Then use strpos() or a preg function to check if it is there. You may also want to check if it is nofollow or not That is the quick and dirty method. I would use cURL instead and XML DOM functions to test all <a> tags. That will prevent your code being fooled or throwing false negatives/positives. Slightly more complicated but works best in my experience. There are tonnes of scripts around to do what you are looking for. Are you doing this as an exercise to learn or what?
function checklinks($url, $html) { $data = file_get_contents($url); if(eregi($html, $data)) { return "Match"; } else { return "No Match"; } } $url = "http://www.example.com/pagexyz.html"; $html = "<a href=\"http://www.example.com\">Example Link</a> - This is sample description text to go with my link."; echo checklinks($url, $html); PHP: That should do the job.
Thanks for the help. I'm building a small SEO script that I'm going to use for some clients. In the past I've done most of this manually or bought expensive software. Either way it's a pain and I want to have certain custom features, so I'm building my own from scratch but I have limited php knowledge (i.e. I've hacked wordpress and made a few simple apps, but that's about it), so I'm learning as I go