博客
关于我
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/

    你可能感兴趣的文章
    Prometheus 安装部署实战
    查看>>
    prometheus 持久化存储方案
    查看>>
    Prometheus 监控系统企业级实战
    查看>>
    Prometheus 监控系统简介
    查看>>
    Prometheus 配置详解
    查看>>
    Prometheus 采集器使用详解
    查看>>
    Prometheus 黑盒监控实战
    查看>>
    prometheus+alertmanager+grafana监控部署教程
    查看>>
    Prometheus+Grafana构建智能化Kubernetes监控系统实战
    查看>>
    Prometheus+SpringBoot应用监控全过程详解
    查看>>
    Prometheus+SpringBoot应用监控全过程详解
    查看>>
    prometheus安装
    查看>>
    Prometheus实战教程:监控Kafka消息
    查看>>
    Prometheus实战教程:监控mysql数据库
    查看>>
    Prometheus实战教程:监控Nginx状态
    查看>>
    prometheus常用exporter下载地址大全
    查看>>
    Prometheus快速搭建与监控Linux系统实战
    查看>>
    prometheus报警与恢复告警的格式
    查看>>
    Pytorch中安装 torch_geometric 详细图文操作(全)
    查看>>
    prometheus监控docker容器实战
    查看>>