Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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-解析谷歌相关搜索(谷歌趋势)_Php_Parsing_Curl_Google Trends - Fatal编程技术网

PHP-解析谷歌相关搜索(谷歌趋势)

PHP-解析谷歌相关搜索(谷歌趋势),php,parsing,curl,google-trends,Php,Parsing,Curl,Google Trends,我需要解析这个urlhttp://www.google.com/trends/fetchComponent?q=swine&cid=TOP_QUERIES_0_0&export=3 我试过: <?php $ch = curl_init("http://www.google.com/trends/fetchComponent?q=swine&cid=TOP_QUERIES_0_0&export=3"); curl_setopt($ch, CURLOPT_RETURNTRANS

我需要解析这个urlhttp://www.google.com/trends/fetchComponent?q=swine&cid=TOP_QUERIES_0_0&export=3

我试过:

<?php
$ch = curl_init("http://www.google.com/trends/fetchComponent?q=swine&cid=TOP_QUERIES_0_0&export=3");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec($ch);
curl_close($ch);
echo $html;
?>
但我只收到

您已达到配额限制。请稍后再试


但是,如果我可以从web浏览器打开该页面,我不会登录,我可以更改搜索词等。因此,从web浏览器它可以工作,但在使用PHP和CURL时,id不会工作

答案就在这个问题上:你已经达到了谷歌趋势(Google Trends)的请求配额。网站管理员不喜欢他们的网站被执行自动请求的脚本所打击。如果您继续发送请求,许多网站将阻止您访问它们。解决方案是将您的请求速度减慢到更合理的速度,使用API(如果可用),联系网站管理员请求提供API,或者从其他地方获取数据。

我每秒不运行10000个请求。我立即或在CURL的第二次请求时收到该错误。所以为了澄清,我可以每隔10-20-30分钟左右通过CURL请求提到的页面,但同时我可以手动从浏览器发出多个请求。