出于某种原因,有时 cURL 会找到网页而不是其他时间,而 simple_html_dom 会找到包含相同网址的网页。
例如:
$url = http://www.youtube.com/results?search_type=search_users&search_query=java&page=7
cURL 页面不是foud:
$curl = curl_init();
curl_setopt($curl, CURLOPT_REFERER, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec( $curl );
curl_close($curl);
if(strpos($content, "404") || $content==""){ echo "**************** PAGE NOT FOUND ****************\n"; return;}
但 html_simple_dom :
是的$content = file_get_html($url);//same url above