Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/134.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用file_get_contents函数,我想获得前几个google结果,而不是全部结果_Php_File Get Contents - Fatal编程技术网

Php 使用file_get_contents函数,我想获得前几个google结果,而不是全部结果

Php 使用file_get_contents函数,我想获得前几个google结果,而不是全部结果,php,file-get-contents,Php,File Get Contents,我已经使用文件获取内容来获取字符串的google结果并显示到网页上 $url = "http://www.google.com/search?q=".$str; $result = file_get_contents($url); echo $result; 但是是否可以只显示前几个结果,比如5个,而不是所有结果?要限制Google搜索结果的数量,请在Google查询中添加参数&num=5 比较

我已经使用文件获取内容来获取字符串的google结果并显示到网页上

$url = "http://www.google.com/search?q=".$str;

$result = file_get_contents($url);

echo $result;

但是是否可以只显示前几个结果,比如5个,而不是所有结果?

要限制Google搜索结果的数量,请在Google查询中添加参数
&num=5

比较