python - 直接点链接可以打开,但是爬不到,url复制到chrome地址栏直接访问会被重定向
PHP中文网
PHP中文网 2017-04-17 17:57:01
0
3
383

想从
http://www.themeasuredmom.com/free-find-the-letter-alphabet-worksheets/

点这个链接

下载这个pdf
http://www.themeasuredmom.com/wp-content/uploads/2014/05/LONG-E-MIXED-read-n-stick.pdf

问题:
直接点链接可以打开,但是爬不到,
url:http://www.themeasuredmom.com/wp-content/uploads/2015/03/UppLowLFW.pdf复制到chrome地址栏直接访问会被重定向,求解决方案

PHP中文网
PHP中文网

认证高级PHP讲师

reply all (3)
左手右手慢动作

It’s probably something in the header

I used this successfully

curl 'http://www.themeasuredmom.com/wp-content/uploads/2015/03/UppLowLFW.pdf' -H 'Cookie: PHPSESSID=u0kukupcva27knobhdm85iir44; __utmt=1; __utma=181216354.576 601741.1466662381.1466662381.1466662381.1; __utmb=181216354.2.10.1466662381; __u tmc=181216354; __utmz=181216354.1466662381.1.1.utmcsr=(direct)|utmccn=(direct)|u tmcmd=(none); wp_woocommerce_session_d3bf8fa04c924fd40bf854486746c07f=f09be06516 50174c93f69896402fb4ac%7C%7C1466835208%7C%7C1466831608%7C%7C6ec57624f089d98b168a f91b3bf007eb' -H 'Origin: http://www.themeasuredmom.com' -H 'Accept-Encoding: gz ip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.8' -H 'User-Agent: Mozilla/5.0 (W indows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.27 04.103 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; chars et=UTF-8' -H 'Accept: */*' -H 'Referer: http://www.themeasuredmom.com/free-find- the-letter-alphabet-worksheets/' -H 'X-Requested-With: XMLHttpRequest' -H 'Conne ction: keep-alive' --data 'action=popupallypro_track_stats&data=2%7C%7Cembed%7C% 7Cview%7C%7C2%7C%7C0%3D%3D%3E&submit_nonce=b783764a2b' --compressed >>test.pdf

The headers above were copied directly from my Chrome

    伊谢尔伦
    Referer: http://www.themeasuredmom.com/free-find- the-letter-alphabet-worksheets/ X-Requested-With: XMLHttpRequest Content-Type: application/x-www-form-urlencoded
      Ty80

      Try to simulate the request header as much as possible like a real browser, such as adding Content-Type, Host, etc.

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!