init xiaoxiang project

This commit is contained in:
2026-04-15 18:12:30 +08:00
commit f539f1bece
160 changed files with 981970 additions and 0 deletions
Binary file not shown.
Binary file not shown.
+15
View File
@@ -0,0 +1,15 @@
import json
import newsetting
tent = newsetting.All_Setting('183.6.7.91',33016,'tk_test')
sql = """
select * from category_detail_log where created_at > '2026-3-29'
"""
a1 = tent.get_shoppingmalls(sql)
for index,b in enumerate(a1):
with open(f'./down/data_{index}.json','w',encoding='utf-8') as f:
f.write(str(b))
+161
View File
@@ -0,0 +1,161 @@
import re
import pymysql
class All_Setting():
def __init__(self,host,port,db):
self.host = host
self.port = port
self.db = db
def remove_symbols(self,text):
pattern = re.compile(r'[^\w\s]')
return pattern.sub('', text)
def get_chinese(self,text,printTxt=False):
# text = "海王星辰(广州智慧城店)"
pattern = r'[^\w\s]'
result = re.sub(pattern, '', text)
if printTxt:
print(result)
return result
def get_shoppingmalls(self,sql):
res_list = []
conn = pymysql.connect(
host= self.host, # 我的IP地址
port=self.port, # 不是字符串不需要加引号。
user='root',
password='Aliyun@7646!',
db=self.db,
charset='utf8mb4'
)
if conn:
print('ok')
cursor = conn.cursor()
res = cursor.execute(sql)
c2 = cursor.fetchall()
return c2
def write_data(self,sql,data):
conn = pymysql.connect(
host= self.host, # 我的IP地址
port=self.port, # 不是字符串不需要加引号。
user='root',
password='Aliyun@7646!',
db=self.db,
charset='utf8mb4'
)
# 拿到游标
if conn:
print("连接成功!")
cursor = conn.cursor()
cursor.executemany(sql,data)
conn.commit()
cursor.close()
def update_data(self,sql):
conn = pymysql.connect(
host= self.host, # 我的IP地址
port=self.port, # 不是字符串不需要加引号。
user='root',
password='Aliyun@7646!',
db=self.db,
charset='utf8mb4'
)
# 拿到游标
if conn:
print("连接成功!")
cursor = conn.cursor()
cursor.execute(sql)
conn.commit()
cursor.close()
def write_data_one(self,sql,data):
conn = pymysql.connect(
host= self.host, # 我的IP地址
port=self.port, # 不是字符串不需要加引号。
user='root',
password='Aliyun@7646!',
db=self.db,
charset='utf8mb4'
)
# 拿到游标
if conn:
print("连接成功!")
cursor = conn.cursor()
cursor.execute(sql,data)
conn.commit()
cursor.close()
import json
# import time,requests
def get_sign_meituan(url, dfpid, data):
url_mtg = "http://118.89.119.254:18003/mt_jym_1_2"
payload = json.dumps({
"url": url,
"data": data,
"dfpid": dfpid,
"method": "POST",
"ua_type": "android"
})
headers = {
'token': 'j760kynsopjfm0sa9ghjwsd',
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
'Content-Type': 'application/json'
}
response1 = requests.request("POST", url_mtg, headers=headers, data=payload)
print(response1.text)
mtgsig1 = response1.json()
return str(mtgsig1)
def get_sign_waimai(url, dfpid, data):
print('我是外卖mtg')
url_mtg = "http://118.89.119.254:18003/get_mt_tg_0507_jym"
payload = json.dumps({
"url": url,
"data": data,
"dfpid": dfpid,
"method": "POST",
# "ua_type": "android"
})
headers = {
'token': 'j760kynsopjfm0sa9ghjwsd',
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
'Content-Type': 'application/json'
}
response = requests.request("POST", url_mtg, headers=headers, data=payload)
mtgsig = response.json()
print(mtgsig)
return str(mtgsig)
def get_Datatext(dataq):
str1 = ''
for i in dataq:
key, value = i, dataq[i]
str2 = f'{key}={value}&'
str1 = str1 + str2
data = str1[0:-1]
return data
tent = All_Setting(host='8.138.160.45',port=3306,db='program_user_list')
tent2 = All_Setting(host='183.6.7.91',port=33016,db='elm_meishi')
# tent3 = All_Setting(host='42.192.49.62',port=3306,db='MT_shop3')
# sql1 = """SELECT distinct prox FROM `MT_shop2`.`category_table` WHERE `created_at` > '2025-3-24' LIMIT 0,1000"""
# prox = tent2.get_shoppingmalls(sql1)[0][0]
# print(prox)
# print(json.loads(prox))
# prox2 = json.dumps(prox)
# print(prox2)
# sql2 = """SELECT distinct `index` FROM `MT_shop2`.`category_table` WHERE `created_at` > '2025-3-24' LIMIT 0,1000"""
# lis = tent2.get_shoppingmalls(sql2)
# for i in lis:
# indexs = (i[0])
# sql4 = f"""update `MT_shop2`.`category_table` set prox = {prox2} WHERE `created_at` > '2025-3-24' """
# tent2.update_data(sql4)
+70
View File
@@ -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)