http://www.hdwallpapersimages.com/
瀏覽器顯示正常,先使用file_get_contents,抓取內容為空白,用ChinaZ的百度蜘蛛和Google蜘蛛類比抓取,還是請求逾時,於是我乾脆複製我瀏覽器的header,用file_get_contents抓取,還是抓取為空白,這是My Code:
$opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\n". "Accept-Encoding:gzip, deflate, sdch\r\n". "Accept-Language:zh-CN,zh;q=0.8,en;q=0.6\r\n". "Cache-Control:max-age=0\r\n". "Cookie:viewed_cookie_policy=yes; __utmt=1; __utma=37938810.875942873.1452954236.1453114091.1453209277.3; __utmb=37938810.30.10.1453209277; __utmc=37938810; __utmz=37938810.1452954236.1.1.utmcsr=bing|utmccn=(organic)|utmcmd=organic|utmctr=hd%20wallpaper; __unam=eb5fde1-1524ad24043-4a580705-62\r\n". "Host:www.hdwallpapersimages.com\r\n". "Proxy-Connection:keep-alive\r\n". "Upgrade-Insecure-Requests:1\r\n". "User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36\r\n" ) ); $context = stream_context_create($opts); echo file_get_contents('http://www.hdwallpapersimages.com', false, $context);
回複內容:
http://www.hdwallpapersimages.com/
瀏覽器顯示正常,先使用file_get_contents,抓取內容為空白,用ChinaZ的百度蜘蛛和Google蜘蛛類比抓取,還是請求逾時,於是我乾脆複製我瀏覽器的header,用file_get_contents抓取,還是抓取為空白,這是My Code:
$opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\n". "Accept-Encoding:gzip, deflate, sdch\r\n". "Accept-Language:zh-CN,zh;q=0.8,en;q=0.6\r\n". "Cache-Control:max-age=0\r\n". "Cookie:viewed_cookie_policy=yes; __utmt=1; __utma=37938810.875942873.1452954236.1453114091.1453209277.3; __utmb=37938810.30.10.1453209277; __utmc=37938810; __utmz=37938810.1452954236.1.1.utmcsr=bing|utmccn=(organic)|utmcmd=organic|utmctr=hd%20wallpaper; __unam=eb5fde1-1524ad24043-4a580705-62\r\n". "Host:www.hdwallpapersimages.com\r\n". "Proxy-Connection:keep-alive\r\n". "Upgrade-Insecure-Requests:1\r\n". "User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36\r\n" ) ); $context = stream_context_create($opts); echo file_get_contents('http://www.hdwallpapersimages.com', false, $context);
你抓取的網站打不開麼
因為網站我也打不開,哈哈哈哈,在你啟動並執行機子上 直接curl 看看有內容麼