def parser_price_detail(self, response): """解析价格""" jquery_data = response.body jquery_data = jquery_data.decode('UTF-8') item = response.meta['item'] jd_item = item['other_parameter'] json_data = Parse_Util.get_json_str(jquery_data) data = json.loads(json_data, 'UTF-8') jd_item['price'] = data[0]['p'] yield item
def parse_comment_detail(self, response): """解析评价""" jquery_data = response.body jquery_data = jquery_data.decode('GBK') item = response.meta['item'] jd_item = item['other_parameter'] json_data = Parse_Util.get_json_str(jquery_data) data = json.loads(json_data, 'UTF-8') jd_item['comment_count'] = data['productCommentSummary'][ 'commentCount'] jd_item['good_count'] = data['productCommentSummary']['goodCount'] jd_item['general_count'] = data['productCommentSummary'][ 'generalCount'] jd_item['bad_count'] = data['productCommentSummary']['score1Count'] jd_item['good_rate'] = data['productCommentSummary']['goodRate'] item_price_link = price_origin_url % (int(item['id'])) # print 'item_price_link ------------ %s' % item_price_link yield Request(item_price_link, callback=self.parser_price_detail, meta={'item': item})