python crawling Jingdong Comments

I, back, your password!

https://blog.csdn.net/weixin_42590877/article/details/99686720?tdsourcetag=s_pcqq_aiomsg

This web site is to help me!

This is what I want to climb, watching the warm  https://item.jd.com/33919692427.html

# In[sy_final]:
#!/usr/bin/python
import requests
import json

# The headers harms me, must have before they can run referer
headers = {
'the User-Agent': 'Mozilla / 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 75.0. Safari 3770.142 / 537.36 ',
' the Referer ':' https://item.jd.com/33919692427.html '
}

This alternate url #
url = 'https://sclub.jd.com/comment/productPageComments.action?callback=fetchJSON_comment98vv382&productId=33919692427&score=0&sortType=5&page=0&pageSize=10&isShadowSku=0&fold=1'
File Open = ( "E: \\ before the end of 2020 to review \\ python \\ military coat 20 reviews 2.txt "," w "); # open a file
for i in range (20): # assume climb 20
url = 'https: // sclub. jd.com/comment/productPageComments.action?callback=fetchJSON_comment98vv382&productId=33919692427&score=0&sortType=5&page=%d&pageSize=10&isShadowSku=0&fold=1 '% I
R & lt requests.get = (URL, headers = headers)
#jd json.loads = ( r.text.lstrip (. 'fetchJSON_comment98vv382 (') The rstrip ( ');'))
#jd = json.loads (r.text)
JD = json.loads (r.text.strip ( 'fetchJSON_comment98vv382();'))
com_list=jd['comments']
for j in com_list:
file.write (j [ 'content'] ); # write to
Print (J [ 'Content']);
a file.write ( '\ R & lt \ n-'); # newline
file.close

Guess you like

Origin www.cnblogs.com/sakuraXiYue/p/12005991.html