I thought this would be fairly simple but it's proving challenging. Google uses https://
now and bing redirects to remove HTTP://
.
How can I grab the top 5 URLs for a given search term?
I've tried several methods (including loading results into an iframe), but keep hitting brick walls with everything I try.
I wouldn't even need a proxy, as I'm talking about a very small amount results to be harvested, and will only use it for 20-30 terms once ever few months. Hardly enough to trigger whiplash from the search giants.
Any help would be much appreciated!
Here's one example of what I've tried:
$query = urlencode("test");
preg_match_all('/<a title=".*?" href=(.*?)>/', file_get_contents("http://www.bing.com/search?q=" . urlencode($query) ), $matches);
echo implode("<br>", $matches[1]);