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

想从
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讲师

모든 응답 (3)
左手右手慢动作

估计是header中的某一个东西

我用这个是成功了

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

上面headers是从我Chrome里直接拷贝的

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

      试试把请求头尽量模拟成真实浏览器的样子,比如加上Content-Type,Host之类的。

        최신 다운로드
        더>
        웹 효과
        웹사이트 소스 코드
        웹사이트 자료
        프론트엔드 템플릿
        회사 소개 부인 성명 Sitemap
        PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!