You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def start_requests(self):
for k,v in self.dic.items():
productId = v[0]
global model
model = v[1]
for score in range(4):
page = 0
while page < 101:
yield Request(self.comment_url.format(productId=productId,score=score,page=page),self.parse,dont_filter=True)
page += 1
time.sleep(1)
def parse(self, response):
datas = json.loads(response.text)['comments']
if datas:
for data in datas:
item = JdParseItem()
for field in item.fields:
if field in data.keys():
item['model'] = model
if field == 'productSales':
item[field] = data.get(field)[0]['saleValue']
else:
item[field] = data.get(field)
yield item