在python中使用curl上传到anonfiles API

r55awzrz  于 2022-11-13  发布在  Python
关注(0)|答案(2)|浏览(194)

我想使用requests模块上传到anonfiles。代码运行了,但是文件没有出现在网站上。下面是我目前的代码:

import requests

files = {
    'file': ('file.txt', open('file.txt', 'rb')),
}
requests = requests.post('https://api.anonfiles.com/upload/?token=mytoken', files=files)

有什么想法,可能是什么问题?提前感谢!

qc6wkl3g

qc6wkl3g1#

您使用了错误的URL -它必须在结尾处没有/

https://api.anonfiles.com/upload

而且似乎没有token也能工作

import requests

files = {
    'file': ('file.txt', open('file.txt', 'rb')),
}

url = 'https://api.anonfiles.com/upload'
response = requests.post(url, files=files)

data = response.json()

print(data['data']['file']['url']['short'])

文件:API

8e2ybdfx

8e2ybdfx2#

你可以给予anonfile,它是一个PyPI库,已经 Package 了anonfiles.com的api。

相关问题