推荐学习书目
› 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
smallgoogle
V2EX  ›  Python

requests 如何保持长链接

  •  
  •   smallgoogle · Mar 27, 2020 · 2913 views
    This topic created in 2378 days ago, the information mentioned may be changed or developed.
    我想的大概是 如何用 requests 访问一个网站 并停留一会。

    所以 requests 可以做到吗?
    wittyfans
        1
    wittyfans  
       Mar 27, 2020
    session
    darylc
        2
    darylc  
       Mar 27, 2020
    停留一会儿?是网站会计算你在某个网页停留时间吗?
    Vhc001
        3
    Vhc001  
       Mar 27, 2020
    停留一会是停留给谁看的,给百度统计看吗?那么 requests 做不到,你需要 BeautifulSoup4 这类库来响应百度统计的短轮询
    daiqiangbudainiu
        4
    daiqiangbudainiu  
       Mar 27, 2020
    @Vhc001 bs4 怎么响应?
    smallgoogle
        5
    smallgoogle  
    OP
       Mar 27, 2020
    @Vhc001 我就是给百度统计看。所以 bs4 如何做到?
    Vhc001
        6
    Vhc001  
       Mar 27, 2020
    @warcraft1236 #4 只要是能渲染 js 的库都行,bs4 只是其中之一
    daiqiangbudainiu
        7
    daiqiangbudainiu  
       Mar 27, 2020
    @Vhc001 没明白啥意思
    stabc
        8
    stabc  
       Mar 27, 2020
    这个不叫『长连接』。
    Vhc001
        9
    Vhc001  
       Mar 27, 2020
    @smallgoogle #5 是这是想让我用几行文字教会你写爬虫吗?自己查资料吧。
    我之前爬百度统计,然后收到百度的律师函了。。。
    gwy15
        10
    gwy15  
       Mar 27, 2020
    你需要的是 pyppeteer……
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2494 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 02:05 · PVG 10:05 · LAX 19:05 · JFK 22:05
    ♥ Do have faith in what you're doing.