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-03-27 10:49:49 +08:00 · 2083 次点击
    这是一个创建于 1463 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我想的大概是 如何用 requests 访问一个网站 并停留一会。

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