33 lines
699 B
Python
33 lines
699 B
Python
import requests
|
|
import json
|
|
import base64
|
|
import socket
|
|
|
|
def getByte(path):
|
|
with open(path, 'rb') as f:
|
|
img_byte = base64.b64encode(f.read())
|
|
img_str = img_byte.decode('utf-8')
|
|
return img_str
|
|
|
|
|
|
img_str = getByte('./emptyJudge5/images/fly/f3fca24bf71ee1824441e6a79aaaec34.jpg')
|
|
|
|
url = ' http://192.168.1.142:14465/isempty'
|
|
|
|
data = {'pic':img_str}
|
|
|
|
json_mod = json.dumps(data)
|
|
|
|
s = requests.session()
|
|
|
|
s.keep_alive = False
|
|
|
|
headers = {
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.100 Safari/537.36',
|
|
}
|
|
|
|
s = requests.session() # 保持会话
|
|
|
|
res = s.post(url=url, data=json_mod, headers=headers)
|
|
|
|
print(res.text) |