init xiaoxiang project
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import requests,newsetting
|
||||
import math
|
||||
|
||||
tent = newsetting.All_Setting('183.6.7.91',33016,'tk_test')
|
||||
def clean_price(price):
|
||||
if price is None:
|
||||
return ''
|
||||
else:
|
||||
return str(price)
|
||||
|
||||
def req_push(items):
|
||||
import requests
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
|
||||
json_data = {
|
||||
'token': 'd7e0759c-8f52-4c82-8102-774da69416d5',
|
||||
'items': items
|
||||
}
|
||||
print(json_data)
|
||||
# input(3)
|
||||
response = requests.post('http://123.60.26.203:9001/service/upload_items/batch', headers=headers, json=json_data)
|
||||
print(response.text)
|
||||
|
||||
def ceil_div(a, b):
|
||||
return math.ceil(a / b)
|
||||
|
||||
sql = "select DISTINCT token,station_id,shop_id,f_id,f_name,s_id,s_name,t_id,t_name,goods_id,title,goods_tag,price_tag,`desc`,image,price,original_price,vip_price,is_immediate from data_completed where create_time > '2026-4-15' and price is not NULL;"
|
||||
|
||||
|
||||
titles = 'token,station_id,shop_id,f_id,f_name,s_id,s_name,t_id,t_name,goods_id,title,goods_tag,price_tag,desc,image,price,original_price,vip_price,is_immediate'.split(',')
|
||||
aa = tent.get_shoppingmalls(sql)
|
||||
items_list = []
|
||||
for i in aa:
|
||||
token,station_id,shop_id,f_id,f_name,s_id,s_name,t_id,t_name,goods_id,title,goods_tag,price_tag,desc,image,price,original_price,vip_price,is_immediate = (i)
|
||||
da = (token,station_id,shop_id,f_id,f_name,s_id,s_name,'','',goods_id,title,goods_tag,price_tag,desc,image,str(price),str(original_price),str(vip_price),str(is_immediate))
|
||||
da2 = {
|
||||
'token': 'd7e0759c-8f52-4c82-8102-774da69416d5',
|
||||
'station_id': station_id,
|
||||
'shop_id': shop_id,
|
||||
'f_id': f_id,
|
||||
'f_name': f_name,
|
||||
's_id': s_id,
|
||||
's_name': s_name,
|
||||
't_id': '',
|
||||
't_name': '',
|
||||
'goods_id': goods_id,
|
||||
'title': title,
|
||||
'goods_tag': goods_tag,
|
||||
'price_tag': price_tag,
|
||||
'desc': desc,
|
||||
'image': image,
|
||||
'price': str(price),
|
||||
'original_price': clean_price(original_price),
|
||||
'vip_price': clean_price(vip_price),
|
||||
'isImmediate': str(is_immediate),
|
||||
}
|
||||
items_list.append(da2)
|
||||
|
||||
num = ceil_div(len(items_list),500)
|
||||
|
||||
for i in range(num):
|
||||
star_num = i*500
|
||||
end_num = (i+1)*500
|
||||
print(f'{star_num}:{end_num}')
|
||||
datas = items_list[star_num:end_num]
|
||||
print(datas)
|
||||
req_push(datas)
|
||||
Reference in New Issue
Block a user