国庆
快乐
转载:美团、大众点评图片上传接口 – 海南仙岛

转载:美团、大众点评图片上传接口

2021年07月14日

转载自hostloc论坛,作者:yoe

上传完成之后会直接返回 上传前的:
>>>图片名称
>>>直链URL

类似这种
http://p0.meituan.net/mmdb/4e6b445e3458f50effe70245218a0533312390.jpg

接口地址>>>
https://maoyan.com/ajax/proxy/admin/mmdb/photos/upload.json

headers三个重要参数>>>

Content-Type
Content-Length
user-agent

重要的事情说三遍 !!! 不需要身份登录 不需要身份登录 不需要身份登录

import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder

def bootstrap():
    path = input('file path: ')
    # path = 'C:/Users/i/Pictures/壁纸9.jpg'
    data = createData(path)
    from_data = createFromData(data, path)
    res = upload(from_data, data)
    print(res['data'][0]['olink'])
# def

def createData(path):
    file_name = path.rsplit('/', 1)[1]
    with open(path, 'rb') as file:
        size = len(file.read())
    headers = {
        'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryzROqT4L0VBRUihWb',
        'Content-Length': str(size),
        'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
    }
    ext = file_name.split('.', 1)[1]
    temp_type = f'image/{ext}'
    return {
        'file_name': file_name,
        'headers': headers,
        'file_type': temp_type
    }
    pass

def createFromData(data, path):
    encode = MultipartEncoder(
        fields={
            'file': (data['file_name'], open(path, 'rb'), data['file_type'])
        },
        boundary='----WebKitFormBoundaryzROqT4L0VBRUihWb'
    )
    return encode

def upload(from_data, data):
    url = 'https://maoyan.com/ajax/proxy/admin/mmdb/photos/upload.json'
    response = requests.post(url, data=from_data, headers=data['headers'])
    result = response.json()
    return result

if __name__ == '__main__':
    bootstrap()

大众点评接口

https://kf.dianping.com/csCenter/access/dealOrder_Help_DP_PC

{
  "Version": "13.4.0",
  "Name": "大众点评客服",
  "DestinationType": "ImageUploader",
  "RequestMethod": "POST",
  "RequestURL": "https://kf.dianping.com/api/file/burstUploadFile",
  "Headers": {
    "CSC-VisitId": "access-ba00ca3b-fa67-4a4f-b5d5-4522e8788ba5"
  },
  "Body": "MultipartFormData",
  "Arguments": {
    "partSize": "1",
    "part": "0",
    "fileName": "meituan",
    "fileID": "453573879545378"
  },
  "FileFormName": "files",
  "URL": "$json:data.uploadPath$"
}

‘Content-Type’: ‘multipart/form-data; boundary=—-WebKitFormBoundaryzROqT4L0VBRUihWb’,

sharex配置,sharex自定义上传设置里导入

点评客服的接口,稳了很久了


sicnature ---------------------------------------------------------------------
Your current IP address is: 3.236.13.53
Your IP address location: 美国弗吉尼亚阿什本亚马逊云
Your IP address country and region: 美国 美国
Your current browser is:
Your current system is:
Original content, please indicate the source:
同福客栈论坛 | 蟒蛇科普海南乡情论坛 | JiaYu Blog
sicnature ---------------------------------------------------------------------
Welcome to reprint. Please indicate the source https://www.myzhenai.com.cn/post/3876.html

没有评论

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注