我試圖從網站中刪除一些內容,但我遇到了一個可能微不足道的問題,但找不到解決方案。對於第一頁,它的作品,但是當我瀏覽(捲曲)下面的頁面時,我仍然得到頁面1的內容,這很奇怪。我想在網站有一定的保護殺,但我無法找到一個方法來識別它們...cURL不適用於特定網站的分頁
<?php
$i = 1;
$links = array();
while($i < 3)
{
$ch = curl_init();
$url = 'http://www.gites-de-france.com/location-vacances-chambre-hotes.html?page=$i&chambre=o&xhtml=O&acc=CHAMBRE,CHAMBRE&order_by=prix&order_by_tri=asc&';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, "http://www.google.fr/");
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$html = curl_exec($ch);
curl_close($ch);
$doc = phpQuery::newDocument($html);
foreach($doc['.vignette a'] as $a){
$url = '';
$links[] .= pq($a)->attr('href');
}
$i++;
}
print_r($links);
?>
是的訣竅是使用cookies! –