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
smallgoogle
V2EX  ›  Python

requests 如何保持长链接

  •  
  •   smallgoogle · 2020 年 3 月 27 日 · 2488 次点击
    这是一个创建于 2162 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我想的大概是 如何用 requests 访问一个网站 并停留一会。

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