簡體   English   中英

使用 php curl 模擬瀏覽器在 ebay 中不起作用

[英]simulate browser with php curl not working in ebay

我正在嘗試將以下 ebay 網頁讀取到 PHP 變量以進行處理: http : //offer.ebay.co.uk/ws/eBayISAPI.dll? ViewBidsLogin&_trksid=p2047675.l2564&rt=nc&item= 321069150620它在沒有任何現代瀏覽器的情況下顯示良好需要登錄。

當我嘗試使用以下代碼將頁面讀取到 PHP 變量時:

    $url="http://offer.ebay.co.uk/ws/eBayISAPI.dll?ViewBidsLogin&_trksid=p2047675.l2564&rt=nc&item=321069150620";
$header = array();
$header[] = 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
$header[] = 'Cache-Control: max-age=0';
$header[] = 'Connection: keep-alive';
$header[] = 'Keep-Alive: 300';
$header[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7';
$header[] = 'Accept-Language: en-us,en;q=0.5';
$header[] = 'Pragma: ';
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)');
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_AUTOREFERER, true); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$string = curl_exec($ch);
curl_close ($ch);
echo $string;

我得到以下頁面http://www.talumets.com/tmp/error.jpg ,要求我輸入照片中的數字以繼續。 有時我的代碼有效,但 95% 的時候它要求我輸入數字。 我也試過 $string= file_get_contents( $url ),但同樣的問題。 知道如何繞過這個嗎?

謝謝,湯姆

您所看到的是 ebay 對諸如您的腳本的驗證碼保護。 我不認為有什么好方法可以繞過它。

您可以嘗試限制每秒請求的比率,並希望您不會觸發驗證碼

理想的解決方案(如果您不想使用 api)將使用多個服務器,每個服務器每秒只有很少的請求。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM