爬取京东网站口红颜色
import requests,json
url=requests.get('https://club.jd.com/comment/productPageComments.action?callback=fetchJSON_comment98&productId=65679377853&score=0&sortType=5&page=0&pageSize=10&isShadowSku=0&fold=1')
# 若打印出是html文件,说明地址有问题,地址是根据检查--评论--header来的
# print(url.text)
data=url.text.replace('fetchJSON_comment98(','').replace(');','')
contents=json.loads(data)
contents1=contents['comments']
for item in contents1:
color=item['productColor']
print(color)
使用python操作表格
import requests,json,openpyxl
<!---->这两行是导入exlsx表格
wk=openpyxl.Workbook()
sheet=wk.create_sheet()
<!---->爬虫的基本步骤
url=requests.get('https://club.jd.com/comment/productPageComments.action?callback=fetchJSON_comment98&productId=65679