Acceptes 2021-11-22 11:12 采纳率: 25%
浏览 12
已结题

用requests.post上传图片到e站实现自动搜索,但post出错


import requests
from fake_useragent import UserAgent
import io
#https://e-hentai.org/?f_shash=nofile&fs_from=  ex搜图
from lxml.html import fromstring
url = 'https://upld.e-hentai.org/image_lookup.php'
jsonpath=r'C:\Users\Accepted\Desktop\python\通用'
proxies={'http':'http://127.0.0.1:7891','https':'http:127.0.0.1:7891'}
headers={
    "Cookie": "ipb_member_id=5778116; ipb_pass_hash=702680826f91a819da80b61be152e9d7; sk=54azub075xa1furqmeh6hn67qzb9; event=1637501119",
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Cache-Control': 'max-age=0',
    'Connection': 'keep-alive',
    'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryB0NrMSYMfjY5r0l1',
    'Host': 'e-hentai.org',
    'Origin': 'https://e-hentai.org',
    'Referer': 'https://e-hentai.org/?f_shash=nofile&fs_from=',
    'Sec-Fetch-Dest': 'document',
    'Sec-Fetch-Mode': 'navigate',
    'Sec-Fetch-Site': 'same-origin',
    'Sec-Fetch-User': '?1',
    'Upgrade-Insecure-Requests': '1',
    'User-Agent': str(UserAgent(path=rf'{jsonpath}\ua.json').random)
}

files = {
    'fs_similar':'on',
    'f_sfile':'search',
    'boundary':'----WebKitFormBoundaryB0NrMSYMfjY5r0l1',
    'file': ('白丝.jpg', open(r'C:\Users\Accepted\Desktop\白丝.jpg', 'rb'), 'image/jpeg')  # image或者file
}
r = requests.post(url=url, headers=headers, files=files,proxies=proxies)
print(r.text)
print(r.status_code)

其中r的内容和post之前的内容是一样的,是files内容有错吗

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 11月30日
    • 创建了问题 11月22日

    悬赏问题

    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog
    • ¥15 Excel发现不可读取的内容