python爬取某种商品所有评论_毕设一:python 爬取苏宁的商品评论

该博客介绍了如何使用Python编写爬虫程序,从苏宁网站上爬取指定商品(如华为mate20pro, vivoz3等)的所有评论。通过设置UserAgent和代理IP来模拟浏览器行为,避免被网站封禁。爬虫首先获取商品信息,然后提取商品的cluster_id,最后根据cluster_id和商品编号分页获取并保存评论内容。" 112947501,10543794,Windows环境下使用geth搭建以太坊私链教程,"['以太坊开发', '区块链', 'geth命令行工具', '私有网络', '智能合约']
摘要由CSDN通过智能技术生成

1 #-*- coding: utf-8 -*-

2 #@author: Tele

3 #@Time : 2019/04/15 下午 8:20

4 importtime5 importrequests6 importos7 importjson8 importre9 from fake_useragent importUserAgent10

11

12 classSNSplider:13 flag =True14 regex_cluser_id = re.compile("\"clusterId\":\"(.{8})\"")15 regex_comment = re.compile("reviewList\((.*)\)")16

17 @staticmethod18 defget_proxy():19 return requests.get("http://127.0.0.1:5010/get/").content.decode()20

21 @staticmethod22 defget_ua():23 ua =UserAgent()24 returnua.random25

26 def __init__(self, kw_list):27 self.kw_list =kw_list28 #评论url 参数顺序:cluser_id,sugGoodsCode,页码

29 self.url_temp = "https://review.suning.com/ajax/cluster_review_lists/general-{}-{}-0000000000-total-{}-default-10-----reviewList.htm"

30 self.headers ={31 "User-Agent": "Mozilla

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值