Python自动爬取淘宝网评论
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import re
import urllib2
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
url='https://rate.tmall.com/list_detail_rate.htm?itemId=41464129793&sellerId=1652490016¤tPage=1'
cont=urllib2.urlopen(url).read()
rex=re.compile(r'\"rateList\":(\[.*?\])\,\"searchinfo\"')
content=rex.findall(cont)[0]
con=json.loads(content, "gbk")
count = len(con)
print len(con)
# count=len(con['rateDetail']['rateList'])
# print count
for i in xrange(count):
print str(i) + " " + con[i]['rateContent']
本文标题:Python自动爬取淘宝网评论
本文链接:https://www.haomeiwen.com/subject/afsdmttx.html
网友评论