0
以下是我的代碼,我試圖抓取以下URL,但由於某些原因,html源代碼根本沒有被刮掉。爲什麼在這個URL上不會發生刮擦?無法刮取Zazzle產品網址
我試圖使用File_get_contents
以及簡單的HTML DOM庫,但它沒有刮。
URL: http://www.zazzle.com/protoceratops_t_shirt-235065458404753105
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
echo get_data('http://www.zazzle.com/protoceratops_t_shirt-235065458404753105');
您是否收到錯誤?該代碼是否僅爲'http:// www.google.com /'返回任何內容? – castis