博客
关于我
Selenium实现微博爬虫
阅读量:182 次
发布时间:2019-02-28

本文共 302 字,大约阅读时间需要 1 分钟。

抓取节点:将每条评论作为一个节点(包含用户信息、评论内容及发布时间等信息)。若一页有20条评论,则节点数量即为20。

节点获取:通过CSS选择器div.card > div.card-feed > div.content找到所有符合条件的节点。

节点处理:逐个遍历节点列表,判断每个节点是否包含“展开全文”链接。操作步骤如下:

  • 检查节点中是否存在p > a[action-type='fl_unfold']元素
  • 判断该链接的显示状态
  • 如果满足条件,且链接文本以“展开全文c”开头:

    • 点击该链接,获取指定位置的评论内容
    • 否则,直接获取评论文本
    • 同时,提取用户信息

    注:该操作需确保唯一性,避免误选其他元素。

    转载地址:http://tdfn.baihongyu.com/

    你可能感兴趣的文章
    Pinia:$patch的使用场景
    查看>>
    Pinia:$subscribe()的使用场景
    查看>>
    Pinpoint对Kubernetes关键业务模块进行全链路监控
    查看>>
    Pinterest 大规模缓存集群的架构剖析
    查看>>
    pintos project (2) Project 1 Thread -Mission 1 Code
    查看>>
    PinYin4j库的使用
    查看>>
    PIP
    查看>>
    pip install goose-extractor // SyntaxError: Missing parentheses in call to 'print'
    查看>>
    pip install mysqlclient报错
    查看>>
    pip install 出现报asciii码错误的解决
    查看>>
    pip throws TypeError: parse() got an unexpected keyword argument ‘transport_encoding‘ 在尝试安装新软件包时
    查看>>
    pip 下载慢
    查看>>
    pip 升级报错AttributeError: ‘NoneType’ object has no attribute ‘bytes’
    查看>>
    pip 安装opencv-python卡死
    查看>>
    pip 安装出现异常
    查看>>
    Pip 安装失败:需要 SSL
    查看>>
    Pip 安装挂起
    查看>>
    pip 或 pip3 为 Python 3 安装包?
    查看>>
    pip 文件损坏导致 pip无法使用 报错 ImportError: cannot import name 'main' from 'pip._int
    查看>>
    pip 无法从 requirements.txt 安装软件包
    查看>>