|
@@ -14,6 +14,8 @@ import sys
|
|
|
from datetime import datetime,timedelta
|
|
|
import json
|
|
|
import pymysql
|
|
|
+from PIL import Image
|
|
|
+import base64
|
|
|
|
|
|
def linkTomySql(host, passwd, db_name, port):
|
|
|
'''连接至数据库返回【db】,v2新增local_infile=1 打开文件导入权限'''
|
|
@@ -81,6 +83,10 @@ def get_shops_info_to_list(db, brand_name, wm_plate, key_name):
|
|
|
shops_info_df.append (shop_info_dict)
|
|
|
return shops_info_df
|
|
|
|
|
|
+def image_to_base64(image_path):
|
|
|
+ with open(image_path, "rb") as image_file:
|
|
|
+ encoded_string = base64.b64encode(image_file.read()).decode("utf-8")
|
|
|
+ return encoded_string
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
host = '124.222.188.59'
|
|
@@ -103,23 +109,34 @@ if __name__ == '__main__':
|
|
|
acctId = keys_dict['mt']['data']['session']['acctId']
|
|
|
shop_id = 19666068
|
|
|
|
|
|
- # file_path = r'C:\Users\ClownHe\Desktop\1业务支持需求单\美-暖冬.gif'
|
|
|
- #
|
|
|
- # files = {'multipart': open(file_path, 'rb')}
|
|
|
- #
|
|
|
- # data = {'needPicPropaganda':1}
|
|
|
- #
|
|
|
- # url = 'https://e.waimai.meituan.com/reuse/product/uploadTool/w/uploadImg'
|
|
|
- #
|
|
|
- # Cookie = cookie = f"token={token}; acctId={acctId}; wmPoiId={shop_id};"
|
|
|
- #
|
|
|
- # header = {
|
|
|
- # 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36',
|
|
|
- # 'Accept': 'application/json, text/plain, */*',
|
|
|
- # 'Cookie': Cookie}
|
|
|
- #
|
|
|
- # resp = requests.post(url,files=files,data=data,headers=header).text
|
|
|
+ file_path = r'C:\Users\ClownHe\Desktop\1业务支持需求单\美-暖冬.gif'
|
|
|
+ # file_path = r'C:\Users\ClownHe\Desktop\1业务支持需求单\ceshi.jpg'
|
|
|
+ base64_str = image_to_base64(file_path)
|
|
|
+ # print(base64_str)
|
|
|
+
|
|
|
+ data = {'multipart':base64_str,'needPicPropaganda':1}
|
|
|
+
|
|
|
+ url = 'https://e.waimai.meituan.com/reuse/product/uploadTool/w/uploadImg'
|
|
|
+
|
|
|
+ Cookie = cookie = f"token={token}; acctId={acctId}; wmPoiId={shop_id};"
|
|
|
+
|
|
|
+ header = {
|
|
|
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36',
|
|
|
+ 'Accept': 'application/json, text/plain, */*',
|
|
|
+ 'Cookie': Cookie}
|
|
|
+
|
|
|
+ # resp = requests.post(url,data=data,headers=header).text
|
|
|
# print(resp)
|
|
|
|
|
|
+ url_save = 'https://e.waimai.meituan.com/reuse/product/food/w/saveMultiImage'
|
|
|
+ json_save = {'wmPoiId':19666068,
|
|
|
+ 'newUrl':'http://p0.meituan.net/business/354250f999e92885a4390e07ad78005f1363077.gif?t=1705908020128',
|
|
|
+ 'spuId':12626543674,
|
|
|
+ 'sequence':2,
|
|
|
+ 'qualityScore':1,
|
|
|
+ 'picExtend':{"source":5}}
|
|
|
+ resp = requests.post(url_save,data=json_save,headers=header).text
|
|
|
+ print(resp)
|
|
|
+
|
|
|
|
|
|
|