ValueError: check_hostname requires server_hostname
来源:3-5 request上传文件操作
weixin_慕哥2269558
2022-07-07
老师报这个错ValueError: check_hostname requires server_hostname怎么改
代码
from email.mime import image
import requests
import json
url = 'https://www.imooc.com/user/postpic’
file = {
‘fileField’:(‘test.jpg’,open(‘D:/test.jpg’,‘rb’),‘image/jpg’),
‘type’:‘1’
}
cookie = {
‘apsid’:‘c1MTllMDA0OWJkNzI0OTIxMjljMGMxMjg1NjFjMDcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOTgzNTAyMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxNTIyMjYyMDIwMUAxNjMuY29tAAAAAAAAAAAAAAAAAGE0MjJhMjk3MDlmOTRlMWNhMWMxN2M5MjFlMzY3NWEwGOnEYrdadGA%3DMD’
}
res = requests.post(url,files=file,cookies=cookie,verify=False).json()
print(‘res’)
1回答
-
Mushishi
2022-07-08
你这个是无论发送什么请求都包这个错误 还是只是上传图像的时候。还有弄一个其他网站上传的试一试。如果你这个时候打开了fiddler 有其他代理,你都关闭一下,然后上传一下。
00