Hello, new at php and I'm stuck with a small script I'm trying to build.
I want to parse search engine results... the only thing I want to return from the SERPs is a list of the links from each page. For a typical Google search, that would be only 10 links.
I've gotten this far:
<?php
$str = file_get_contents("http://www.google.com/search?hl=en&rlz=1T4GGIH_enUS222US222&q=leaf+frogs&btnG=Search");
preg_match_all("/<a +href *= *[\"']? *([^\"' >]*)/i", $str, $allurls);
$links = $allurls[1];
for ($i=0; $i<count($links); $i++) {
echo htmlentities($links[$i]) . "<br>\n";
}
?>
You'll see that it correctly returns ALL links from the page. Now I need to parse out only the 10 links to the actual results from the search query.
Can anyone help me please? I appreciate it...