Python如何使用Chrome插件实现爬虫-创新互联

小编这次要给大家分享的是Python如何使用Chrome插件实现爬虫,文章内容丰富,感兴趣的小伙伴可以来了解一下,希望大家阅读完这篇文章之后能够有所收获。

成都创新互联公司专业为企业提供建华网站建设、建华做网站、建华网站设计、建华网站制作等企业网站建设、网页设计与制作、建华企业网站模板建站服务,十多年建华做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

做电商时,消费者对商品的评论是很重要的,但是不会写代码怎么办?这里有个Chrome插件可以做到简单的数据爬取,一句代码都不用写。下面给大家展示部分抓取后的数据:

Python如何使用Chrome插件实现爬虫

可以看到,抓取的地址,评论人,评论内容,时间,产品颜色都已经抓取下来了。那么,爬取这些数据需要哪些工具呢?就两个:

1. Chrome浏览器;

2. 插件:Web Scraper

插件下载地址:https://chromecj.com/productivity/2018-05/942.html

最后,如果你想自己动手抓取一下,这里是这次抓取的详细过程:

1. 首先,复制如下的代码,对,你不需要写代码,但是为了便于上手,复制代码还是需要的,后续可以自己定制和选择,不需要写代码。

{
  "_id": "jdreview",
  "startUrl": [
    "https://item.jd.com/100000680365.html#comment"
  ],
  "selectors": [
    {
      "id": "user",
      "type": "SelectorText",
      "selector": "div.user-info",
      "parentSelectors": [
        "main"
      ],
      "multiple": false,
      "regex": "",
      "delay": 0
    },
    {
      "id": "comments",
      "type": "SelectorText",
      "selector": "div.comment-column > p.comment-con",
      "parentSelectors": [
        "main"
      ],
      "multiple": false,
      "regex": "",
      "delay": 0
    },
    {
      "id": "time",
      "type": "SelectorText",
      "selector": "div.comment-message:nth-of-type(5) span:nth-of-type(4), div.order-info span:nth-of-type(4)",
      "parentSelectors": [
        "main"
      ],
      "multiple": false,
      "regex": "",
      "delay": "0"
    },
    {
      "id": "color",
      "type": "SelectorText",
      "selector": "div.order-info span:nth-of-type(1)",
      "parentSelectors": [
        "main"
      ],
      "multiple": false,
      "regex": "",
      "delay": 0
    },
    {
      "id": "main",
      "type": "SelectorElementClick",
      "selector": "div.comment-item",
      "parentSelectors": [
        "_root"
      ],
      "multiple": true,
      "delay": "10000",
      "clickElementSelector": "div.com-table-footer a.ui-pager-next",
      "clickType": "clickMore",
      "discardInitialElements": false,
      "clickElementUniquenessType": "uniqueHTMLText"
    }
  ]
}

分享标题:Python如何使用Chrome插件实现爬虫-创新互联
网页链接:https://www.cdcxhl.com/article12/deopdc.html

成都网站建设公司_创新互联,为您提供商城网站网站建设外贸网站建设静态网站微信小程序搜索引擎优化

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都seo排名网站优化