我试图使用CURL函数从其他网站获取数据,如谷歌反向链接,雅虎索引页面,whois info等,但在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);
}
}帮我从谷歌,雅虎和sowm whois网站获得无限的查询。这段代码有什么问题?
发布于 2011-09-01 16:57:06
我认为你必须为此使用YQL!
示例http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/
http://www.brighthub.com/hubfolio/matthew-casperson/articles/54673.aspx
更新
只需查看源代码https://github.com/jamespadolsey/jQuery-Plugins/blob/master/cross-domain-ajax/jquery.xdomainajax.js
还有一个网络控制台,你可以在其中测试任何查询-让我们下载当前页面=)
http://developer.yahoo.com/yql/console/?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Ffinance.yahoo.com%2Fq%3Fs%3Dyhoo%22#h=select%20%20*%20from%20html%20where%20url%3D%22http%3A//stackoverflow.com/questions/7253665/file-get-contents-unlimited-queries-how-to/7268078%23comment-8764764%22使用php http://developer.yahoo.com/yql/guide/yql-code-examples.html#yql_php的代码示例
但请仔细阅读文档-没有什么是完美的,YQL有局限性
https://stackoverflow.com/questions/7253665
复制相似问题