I was wondering how I could go about reading HTML documents on other sites using PHP. I have tried searching the internet and through some of the tutorials and references, and have found how to read XML, but nothing about HTML. Does anyone have any ideas how to do this, or where I can find out? Specifically, I would like to search other sites for certain tags and text, like anchor tags.
Something like this ... simple but it's the general idea. <?php $file = file_get_contents("http://www.example.com"); $pattern = "http:\/\/www\.example\.com"; if (preg_match("/$pattern/",$file)) echo "Good"; else echo "Bad"; ?>
yea, you can use file_get_contents. But if your webhost has disabled this, you can use the cURL extensions. They are much more flexible and also support cool stuff like HTTPS and Proxies. http://php.net/curl Thomas