如何通过curl操作获得无限查询?
我正在尝试使用 CURL 函数从其他网站获取数据,例如 google 反向链接、yahoo 索引页、whois 信息等。但在 5-10 次查询后,我的 IP 或我的服务器 IP 被阻止,并且没有显示任何值。这是我正在使用的 Curl 函数:
function getPage ($url) {
if (function_exists("curl_init")) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
return curl_exec($ch);
curl_close($ch);
} else {
return file_get_contents($url);
}
}
帮助我从 Google、Yahoo 和 sowm whois 网站获取无限查询。这段代码有什么问题?
I am trying to get data using CURL function from other websites, like google backlinks, yahoo index pages, whois info etc. but after 5-10 queries my IP or my server IP is blocked and it shows no value. Here's the Curl function I am using:
function getPage ($url) {
if (function_exists("curl_init")) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
return curl_exec($ch);
curl_close($ch);
} else {
return file_get_contents($url);
}
}
Help me to get unlimited queries from Google, Yahoo and sowm whois website. What's wrong with this code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你必须使用 YQL !
例子
http://james.padolsey.com/javascript/cross-domain- requests-with-jquery/
http://www.brighthub.com/hubfolio/matthew-casperson/articles/54673.aspx
UPD
只需查看源代码https://github.com/jamespadolsey/jQuery-Plugins/blob/master/cross-domain-ajax/jquery.xdomainajax.js
还有一个网络控制台,您可以在其中测试任何查询 -让我们下载当前页面 =)
php 代码示例 http://developer.yahoo.com/yql/guide/yql-code-examples.html#yql_php
但是请仔细阅读文档 - 没有什么是完美的,YQL 有局限性
I think you must use YQL for this !
examples
http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/
http://www.brighthub.com/hubfolio/matthew-casperson/articles/54673.aspx
UPD
just look at source code https://github.com/jamespadolsey/jQuery-Plugins/blob/master/cross-domain-ajax/jquery.xdomainajax.js
There is also webconsole where you can test any queries - let's download current page =)
code examples with php http://developer.yahoo.com/yql/guide/yql-code-examples.html#yql_php
But read carefully documentation - nothing is perfect and YQL have limitations