V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
Walter0108
V2EX  ›  Python

为什么这个网址我怎么都抓不下内容来?

  •  
  •   Walter0108 · 2017-10-20 16:41:25 +08:00 · 2780 次点击
    这是一个创建于 2352 天前的主题,其中的信息可能已经有所发展或是发生改变。

    网址: https://stats.nba.com/stats/scoreboard/?GameDate=10/18/2017&LeagueID=00&DayOffset=0

    按理来说 urllib 就够用了,尝试了使用代理 IP 和伪装成浏览器,然而依然没有成功。。。

    具体的表现是一直保持运行,没有响应。

    求各位指教

    8 条回复    2017-10-24 17:56:59 +08:00
    b821025551b
        1
    b821025551b  
       2017-10-20 19:02:09 +08:00
    经 @hxsf 和好多位大神指示,header 里面只要同时有 UA 和 Accept-Language 就行了。

    https://gist.github.com/thomasxu1991/0d9e5e7672cffbd9137fd065107dfa25
    Walter0108
        2
    Walter0108  
    OP
       2017-10-20 20:13:57 +08:00
    @b821025551b 十分感谢然鹅似乎仍然不 work。。。。http://paste.ubuntu.com/25778591/
    byfar
        3
    byfar  
       2017-10-20 22:39:14 +08:00
    curl 'https://stats.nba.com/stats/scoreboard/?GameDate=10/18/2017&LeagueID=00&DayOffset=0' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.8,en;q=0.6' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'Referer: https://www.v2ex.com/t/399301' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' --compressed
    Walter0108
        4
    Walter0108  
    OP
       2017-10-20 23:12:13 +08:00
    @byfar 嗯 curl 测过了但是 py 依然失败。。。代码贴在 2 楼了😓
    mingyun
        5
    mingyun  
       2017-10-20 23:26:41 +08:00
    3 楼正解
    mianju
        6
    mianju  
       2017-10-21 07:51:54 +08:00   ❤️ 1
    有时候可以借助这个神器 https://curl.trillworks.com
    Walter0108
        7
    Walter0108  
    OP
       2017-10-22 00:46:34 +08:00
    谢谢各位我解决了这个问题。楼上的代码和工具都很赞。
    wingor
        8
    wingor  
       2017-10-24 17:56:59 +08:00
    @mianju
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3499 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 10:34 · PVG 18:34 · LAX 03:34 · JFK 06:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.