Skip to content

Instantly share code, notes, and snippets.

@utgwkk
Created August 24, 2015 19:52
Show Gist options
  • Save utgwkk/6ab5eddf313e34d511c8 to your computer and use it in GitHub Desktop.
Save utgwkk/6ab5eddf313e34d511c8 to your computer and use it in GitHub Desktop.
Gyazoに画像upするやつのテスト
YOUR_ACCESS_TOKEN = 'INSERT YOUR ACCESS TOKEN'
import requests
import sys
if len(sys.argv) == 1:
print('ファイル名を指定してください')
sys.exit()
url = "https://upload.gyazo.com/api/upload"
r = requests.post(url, data={'access_token': YOUR_ACCESS_TOKEN}, files={'imagedata': open(sys.argv[1], 'rb')})
data = r.json()
if 'permalink_url' in data:
print("アップロードに成功しました")
import webbrowser
webbrowser.open(data['permalink_url'])
else:
print(r.status_code)
print(r.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment