爬取京东商品评分
import requests
import json
def jd(url):
id = url.replace('https://item.jd.com/', '').replace('.html', '')
params = {
'callback': 'fetchJSON_comment98',
'productId': id,
'score': 0,
'sortType': 5,
'page': 0,
'pageSize': 10,
'isShadowSku': 0,
'fold': 1,
}
url ='http://club.jd.com/comment/productPageComments.action'
res = requests.get(url,params=params)
json_str = res.text[20:-2]
info_dic =json.loads(json_str)
goodRateShow=info_dic.get('productCommentSummary').get('goodRateShow')
print(goodRateShow)
return goodRateShow
if __name__ == '__main__':
jd('https://item.jd.com/2338719.html')