Maison >développement back-end >tutoriel php >如何用PHP抓取网站HTML
怎么用PHP抓取网站HTML
连接地址
http://detail.tmall.com/item.htm?spm=a230r.1.0.0.MlI5e4&id=40364502055&ad_id=&am_id=&cm_id=140105335569ed55e27b&pm_id=&abbucket=12
<br /><?php <br /> $url="http://detail.tmall.com/item.htm?spm=a230r.1.0.0.MlI5e4&id=40364502055&ad_id=&am_id=&cm_id=140105335569ed55e27b&pm_id";<br /> $content = getcurl($url);<br /> echo $content;<br /><br /> <br /> function getcurl($url){<br /> $ch = curl_init(); <br /> curl_setopt($ch, CURLOPT_URL, $url);<br /> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br /> curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);<br /> curl_setopt($ch, CURLOPT_MAXREDIRS,20);<br /> $file_contents = curl_exec($ch);<br /> return $file_contents;<br /> curl_close($ch);<br /> }<br />?><br />