chrome 插件 抓取网页qq聊天记录(爬取这些数据需要哪些工具?(上)|小编分享)
优采云 发布时间: 2022-02-20 12:07chrome 插件 抓取网页qq聊天记录(爬取这些数据需要哪些工具?(上)|小编分享)
这次想和大家分享一下Python是如何使用Chrome插件实现爬虫的。文章 内容丰富。有兴趣的朋友可以过来了解一下。希望看完这篇文章,你能有所收获。
在做电商的时候,消费者对产品的评论很重要,但是如果他们不知道怎么写代码呢?这是一个无需编写任何代码即可进行简单数据爬取的 Chrome 插件。下面显示了一些捕获的数据:
可以看到,爬取的地址、评论者、评论内容、时间、商品颜色都已经被抓取。那么,抓取这些数据需要哪些工具呢?只有两个:
1. Chrome 浏览器;
2. 插件:网络爬虫
插件下载地址:
最后,如果你想自己抢,这里是这个抢的详细过程:
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"
}
]
}
2. 然后打开chrome浏览器,在任意页面同时按下Ctrl+Shift+i,在弹窗中找到Web Scraper,如下:
3. 如下
4. 如图,粘贴上面的代码:
5. 如图,如果需要自定义URL,注意替换。URL 后面的#comment 是评论的直接链接,不能删除:
6. 如图:
7. 如图:
8. 如图,点击抓取后,会自动打开需要抓取的页面,不要关闭窗口,等待完成。
9. 最后,点击下载到计算机并保存数据。
使用此工具的好处是:
1. 无需编程;
2.京东的评论基本可以用这个脚本,修改对应的url即可;
3.如果要抓取的评论少于1000条,这个工具会很方便,所有数据都会自动下载;
使用注意事项:
1. 已经抓取过一次的数据会被记录下来,如果立即再次抓取则不会保存。建议关闭浏览器重新打开再试一次;
2.爬取次数:1000以内没有问题,可能是京东直接根据IP屏蔽了更多的爬取;
看完这篇文章关于Python如何使用Chrome插件实现爬虫,如果你觉得文章的内容写的不错,可以分享给更多人看到。