2011-08-31 52 views
0

我想從其他網站,如谷歌反向鏈接,雅虎索引頁面,whois信息等使用CURL功能獲取數據,但5-10後查詢我的IP或我的服務器IP被阻止,並沒有顯示任何值。這裏是我使用的捲曲功能:如何通過捲曲操作獲取無限查詢?

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網站獲得無限制的查詢。這段代碼有什麼問題?

回答

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

另外也Web控制檯,您可以測試任何疑問 - 讓我們下載當前頁=)

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有侷限性

+0

您好Fivell,這http://james.padolsey.com/javascript/cross-domain-requests -with-jquery /看起來不錯,但我如何在我的php中實現,我的意思是,我需要完整的代碼,因爲我不太熟悉YQL。謝謝。 –

+0

更新了我的回答 – Fivell

+0

謝謝Fivell的所有鏈接。我會盡我所能來得到這些東西,我希望我會得到我需要的atm :) –