這個網站,為啥我用file_get_contents抓取不到任何內容?

來源:互聯網
上載者:User
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 看看有內容麼

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.