Commit 9a053720 authored by rico.liu's avatar rico.liu

update SN price

parent 666b5380
......@@ -237,7 +237,7 @@ def checkData(check_data):
elif "suning" in str(main_url):
try:
main_url = 'http://product.suning.com/0000000000/11673575307.html'
#main_url = 'http://product.suning.com/0000000000/11673575307.html'
sku = re.findall(".com/(.*?).html",main_url)[0]
main_url_ = 'https://product.suning.com/' + sku + '.html'
r = get_response(session,main_url_,headers)
......@@ -277,13 +277,46 @@ def checkData(check_data):
source_list.append(source)
else:
str_price = html.xpath("//a[@id='addCart2']/@sa-data")
str1 = re.findall("'prdid':'(.*?)','",str(str_price))[0] #为了拼接所需要的url,需要三个字段
str2 = re.findall("'shopid':'(.*?)','", str(str_price))[0] #为了拼接所需要的url,需要三个字段
str3 = html.xpath("//input[@name='procateCode']/@value")[0] #为了拼接所需要的url,需要三个字段
real_url = f'https://pas.suning.com/nspcsale_0_{str1}_{str1}_{str2}_10_010_0100100_157122_1000000_9017_10106_Z001___{str3}.html?callback=pcData'
try:
price_response = requests.get(real_url,timeout=5)
sn_price = re.findall('"promotionPrice":"(.*?)",', price_response.text)[0]
except:
sn_price = price
if len(sn_price) != 0:
price_list.append(sn_price)
print('通过')
result. append('通过')
id_all.append(date_id)
sku_list.append(sku)
name_list.append(name)
url_list.append(main_url)
source_list.append(source)
else:
sn_price = price
price_list.append(sn_price)
print('该地区不销售(北京市丰台区)')
result. append('该地区不销售(北京市丰台区)')
id_all.append(date_id)
sku_list.append(sku)
name_list.append(name)
url_list.append(main_url)
source_list.append(source)
'''
str11 = html.xpath("//input[@id='curPartNumber']/@value")[0]
str22 = html.xpath("//input[@id='shop_code']/@value")[0]
str33 = html.xpath("//input[@name='procateCode']/@value")[0]
real_url = f'https://pas.suning.com/nspcsale_0_{str11}_{str11}_{str22}_10_010_0100100_157122_1000000_9017_10106_Z001___{str33}.html?callback=pcData'
price_response = requests.get(real_url)
sn_price = re.findall('"promotionPrice":"(.*?)",', price_response.text)[0]
sn_price = price
#if len(sn_price) != 0:
price_list.append(sn_price)
print('通过')
......@@ -293,7 +326,7 @@ def checkData(check_data):
name_list.append(name)
url_list.append(main_url)
source_list.append(source)
'''
else:
sn_price = price
price_list.append(sn_price)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment