简体   繁体   English

尝试发布到gfycat.com时,Python请求提供错误信息(“连接已中止。”,错误(“(104,'ECONNRESET')”,)))

[英]Python requests giving error ('Connection aborted.', error(“(104, 'ECONNRESET')”,)) when attempting to post to gfycat.com

I am executing the code: 我正在执行代码:

import requests

clientID = redacted
secret =redacted

filename = "temp2.gif"
datakey = '{ "title":"random title"}'

r = requests.post("https://api.gfycat.com/v1/gfycats", data = datakey)
gfyname = r.json()["gfyname"]
print(r.json())
print(gfyname)

params_ = {'client_id': clientID, 'client_secret': secret, 'grant_type': 'client_credentials'}

r = requests.post('https://api.gfycat.com/v1/oauth/token', data=str(params_))

access_token = r.json()['access_token']

headers = {'Authorization': 'Bearer {}'.format(access_token)}
print(headers)
data = {'key': gfyname}
url = "https://filedrop.gfycat.com"
files = {gfyname: open(filename, 'rb')}

r = requests.post(url, data=data, files=files, headers=headers)
print(r)

It all executes fine until the very last request.post() call which is when I receive the error message: 一切执行正常,直到最后一个request.post()调用,这是我收到错误消息的时间:

requests.exceptions.ConnectionError: ('Connection aborted.', error("(104, 'ECONNRESET')",))

I have verified the requests endpoints/params with the gfycat api documentation. 我已经使用gfycat api文档验证了请求端点/参数。 I have checked the output of the headers and the access_token . 我已经检查了headersaccess_token的输出。 I have read through the requests documentation and I did find a few things to which I fixed. 我已经阅读了请求文档,确实发现了一些我要解决的问题。 and now I am stuck here, trying to figure out why the connection is aborting. 现在我被困在这里,试图弄清连接为什么中断。

use pfycat 使用pfycat

import pfycat
c = pfycat.Client("client_id", "client_secret")
r = c.upload('banana.gif')
print(r)

alternatively: look how pfycat does it 或者:看看pfycat是如何做到的

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 连接中止。,Django 中的错误(104,“对等连接重置”) - Connection aborted., error(104, 'Connection reset by peer') in Django Python-请求lib-错误(“连接已中止。”,BadStatusLine(“''”,)) - Python - requests lib - error ('Connection aborted.', BadStatusLine(“''”,)) Python 请求获取 ('Connection aborted.', BadStatusLine("''",)) 错误 - Python Requests getting ('Connection aborted.', BadStatusLine("''",)) error 使用 python 请求获取 ('Connection aborted.', OSError(0, 'Error') 错误 - Getting ('Connection aborted.', OSError(0, 'Error') errors with python requests Python: requests.exceptions.ConnectionError: ('Connection aborted.', OSError(“(54, 'ECONNRESET')”,)) - Python: requests.exceptions.ConnectionError: ('Connection aborted.', OSError(“(54, 'ECONNRESET')”,)) 使用请求时,“连接已终止。” - 'Connection aborted.'when using requests Python请求'连接中止。' 如果它将以cronjob开始 - Python requests 'Connection aborted.' if it will started with a cronjob 如何修复“连接中止”。 使用 BeautifulSoup 在 Python 中出错 - How to fix 'Connection aborted.' error in Python with BeautifulSoup Python 网络抓取错误('连接中止',OSError(“(10060,'WSAETIMEDOUT')”)) - Python Webscraping Error ('Connection aborted.', OSError(“(10060, 'WSAETIMEDOUT')”)) 如何在 Python 中跳过“Connection aborted.”、OSError(0, 'Error')? - How can I skip 'Connection aborted.', OSError(0, 'Error') in Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM