I would like to create a PHP script that will go to another website (given a URL) and check the page source of that page for a certain string of data.
I actually have a way of doing it right now, but looking for an alternative way.
Right now I'm using the file_get_contents php function to read in the page source of the URL into a variable.
$link = "www.example.com";
$linkcontents = file_get_contents($link);
Then I use the strpos php function to search the page for the string I'm looking for:
$needle = "<div>find me</div>";
if (strpos($linkcontents, $needle) == false) {
echo "String not found";
} else {
echo "String found";
}
I have heard the cURL command is good for handling things that have to do with URLs, I'm just not sure how I would use it to do what I'm doing with file_get_contents and strpos functions combined like I have put above.
Or if there is another way to do it, I'm all ears :-)