开发者

PHP file_get_contents on a Google search?

开发者 https://www.devze.com 2023-01-25 12:10 出处:网络
I\'m trying to use PHP to return the resultant HTML of a 开发者_C百科Google search. So for instance

I'm trying to use PHP to return the resultant HTML of a 开发者_C百科Google search.

So for instance

<?php
$file = file_get_contents('http://www.example.com',false);
echo $file;
?>

will return the HTML contents of example.com. The problem is, when I try to do this on a Google search URL, e.g., http://www.google.com/#sclient=psy&hl=en&q=cats, it returns the HTML from the main Google page and NOT the search results for 'cats'.

What's the easiest way to do this?


You want a URL of this form:

http://www.google.com/search?q=cats

The URL you're using is for their new "instant search"


OK, I've answered my own question. Sorry. If I turn Google Insant off, it works fine on a URL like http://www.google.com/search?hl=en&q=cats

Thanks anyway!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号