推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
kingmo888
V2EX  ›  Python

咨询 python3 urllib,访问不了

  •  
  •   kingmo888 · Jul 9, 2016 · 3153 views
    This topic created in 3742 days ago, the information mentioned may be changed or developed.

    http://www.czce.com.cn/portal/exchange/2015/datadaily/20151111.htm

    为何这个地址抓到的结果是

    b'<html><head><title>Request Rejected</title></head><body>The requested URL was rejected. Please consult with your administrator.

    Your support ID is: 13212746783469538584</body></html>'

    构建了一个常规的 header

    请教。。谢谢。

    4 replies  •  2016-07-10 16:02:18 +08:00
    linauror
        1
    linauror  
       Jul 9, 2016
    设置 headers 即可,主要是 user_agent
    okKO
        2
    okKO  
       Jul 9, 2016
    Jblue
        3
    Jblue  
       Jul 10, 2016
    抓包分析一下
    raycool
        4
    raycool  
       Jul 10, 2016
    import requests

    url='http://www.czce.com.cn/portal/exchange/2015/datadaily/20151111.htm'
    header = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17'
    }
    r= requests.get(url,headers=header)
    print r.text

    我说网址这么顺眼,原来前东家。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5584 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 01:45 · PVG 09:45 · LAX 18:45 · JFK 21:45
    ♥ Do have faith in what you're doing.