https://imgur.com/register
https://api.imgur.com/oauth2/addclient
Wenn Sie einreichen, werden "Client ID" und "Client Secret" ausgestellt. Für anonyme Uploads benötigen Sie jedoch lediglich eine "Client-ID".
client_id = 'YOUR CLIENT ID'
image_path = 'path/to/your/image'
import requests
headers = {
'authorization': f'Client-ID {client_id}',
}
files = {
'image': (open(image_path, 'rb')),
}
r = requests.post('https://api.imgur.com/3/upload', headers=headers, files=files)
import json
print(json.loads(r.text)['data']['link'])
image_url = 'YOUR IMAGE URL'
client_id = 'YOUR CLIENT ID'
import requests
headers = {
'authorization': f'Client-ID {client_id}',
}
files = {
'image' : requests.get(image_url).content
}
r = requests.post('https://api.imgur.com/3/upload', headers=headers, files=files)
import json
print(json.loads(r.text)['data']['link'])