Add the cartype scripts, incremental runner, scheduler helper, and project notes so the project can be versioned and pushed to the remote repository.
161 lines
4.6 KiB
Python
161 lines
4.6 KiB
Python
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) |