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

爬虫遇到在浏览器中刷新三次页面才能打开的网站

  •  
  •   ranlele · Jul 8, 2019 · 3919 views
    This topic created in 2530 days ago, the information mentioned may be changed or developed.
    爬虫遇到在浏览器中刷新三次页面才能打开的网站怎么办,第一次刷新,粉丝,关注,作品全是 null,第二次也是 null,第三次刷新才能拿到具体的数值,有大佬分享下思路吗? https://live.kuaishou.com/profile/3xsm4gufvu5cfhm
    Supplement 1  ·  Jul 8, 2019
    带着 session,访问三次,依然获取不到数据。(最主要参数为 did )
    ranlele
        1
    ranlele  
    OP
       Jul 8, 2019
    这是快手的个人信息页面
    matthewz
        2
    matthewz  
       Jul 8, 2019
    设置 cookie 就行了啊
    ranlele
        3
    ranlele  
    OP
       Jul 8, 2019
    自己尝试的第一次访问,返回 did,第二次,第三次带着 did 使用 session 访问,依然获取不到数据。
    Takamine
        4
    Takamine  
       Jul 8, 2019
    那就用 selenium 刷新三次页面怎么样:doge:。
    holajamc
        5
    holajamc  
       Jul 8, 2019
    Cookie 变化 用 mitmproxy 抓包康康
    ranlele
        6
    ranlele  
    OP
       Jul 8, 2019
    selenium 开无头模式就不行。不开无头模式可以使用 did 参数。 cookie 没有变化。
    holajamc
        7
    holajamc  
       Jul 8, 2019   ❤️ 1
    https://zhaoji.wang/how-to-detect-chrome-headless/
    ranlele
        8
    ranlele  
    OP
       Jul 8, 2019
    @holajamc 我再尝试一下,使用无头模式。
    TypeErrorNone
        9
    TypeErrorNone  
       Jul 8, 2019   ❤️ 1
    说明返回数据不是用的 url 参数,是根据 cookie 中的数据来获取的。
    你每次有新的 url 就先访问下,记录 cookie,再带着 cookie 访问一次拿数据。
    ranlele
        10
    ranlele  
    OP
       Jul 8, 2019
    @TypeErrorNone 我觉得,可能就是对这个 cookie 中的数值进行操作的。刷新三次,发送了好多个请求,我现在在模拟这些请求。
    opengps
        11
    opengps  
       Jul 9, 2019
    等待时间不够所以为 null 吧,加点延时进去再爬取
    keji
        12
    keji  
       Jul 9, 2019 via Android
    带上 cookie did 应该就可以了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2625 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 66ms · UTC 16:03 · PVG 00:03 · LAX 09:03 · JFK 12:03
    ♥ Do have faith in what you're doing.