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

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 ---------------------------------------------------------------------
I P 地 址: 3.133.108.172
区 域 位 置: 美国
系 统 信 息: 美国
Original content, please indicate the source:
同福客栈论坛 | 蟒蛇科普海南乡情论坛 | JiaYu Blog
sicnature ---------------------------------------------------------------------
Welcome to reprint. Please indicate the source https://myzhenai.com.cn/post/3876.html

没有评论

发表回复

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