gpt4 book ai didi

python - Python 中的 JSON GET 和 POST

转载 作者:太空宇宙 更新时间:2023-11-03 14:01:18 25 4
gpt4 key购买 nike

我目前正在开发自动化约会应用程序,尤其是一款名为 Fruitz 的法国应用程序。

我对 api 进行了逆向工程,以便获得 POST、GET 序列。

我正在尝试这种功能:

def set_location(location_user):
try:
u= '....appspot.com:443/.../location'
d= requests.post(u, headers=headers, timeout=0.7,data=location_user)
gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
except KeyError:
raise

使用这些 header :

headers = {
'User-Agent':'okhttp/3.6.0',
'Host':'....appspot.com:443',
'connection' : 'Keep-Alive',
'Content-type' : 'application/json',
'x-...-uuid': '...',
'x-...-token': '...'

我目前遇到这个问题:

Traceback (most recent call last):
File "<console>", line 1, in <module>
File "F:\DEV\OPU\DEV\fruitz.py", line 696, in set_location
d= requests.post(u, headers=headers, timeout=0.7,data=location_user)
File "c:\users\jules\miniconda3\lib\site-packages\requests\api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "c:\users\jules\miniconda3\lib\site-packages\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "c:\users\jules\miniconda3\lib\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "c:\users\jules\miniconda3\lib\site-packages\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "c:\users\jules\miniconda3\lib\site-packages\requests\adapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='....appspot.com', port=443): Max retries exceeded with url: .../location (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))

有什么想法吗?

朱尔斯

最佳答案

按照mVChr的建议修复证书或者在requests.post中添加verify=False(也可以通过证书验证http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification)

关于python - Python 中的 JSON GET 和 POST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52065588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com