Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
#!/usr/bin/env python
Upload image to in terminal.
from __future__ import print_function
import sys
import requests
domain = '{}'
api = '{}'
upload = 'upload'
photo = 'photo/{}'
files = 'files/{}'
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) \
AppleWebKit/537.36 (KHTML, like Gecko) \
Chrome/30.0.1599.114 Safari/537.36"
def upload_image(path):
with open(path, 'rb') as image:
imgdata = {'file': image}
rsp =, headers=FAKE_UA, files=imgdata)
xid = rsp.json()['xid']
photo_info = requests.get(
api.format(photo.format(xid)), headers=FAKE_UA).json()
return api.format(files.format(photo_info['file']))
if __name__ == '__main__':
print(upload_image(sys.argv[1]), file=sys.stdout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.