Created
August 24, 2015 08:39
-
-
Save moyashi/6089cc93ae25dbcfff56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: utf-8 | |
import os | |
import requests | |
import clipboard | |
host = "192.168.0.1" | |
dir = "FlashAir" | |
fname = "CLIP.TXT" | |
fpath = "%s/%s" % (dir, fname) | |
if not os.path.exists(dir): | |
os.mkdir(dir) | |
f = open(fpath, "w") | |
t = clipboard.get().encode("shift-jis").replace("\r", "\r\n") | |
f.writelines(t) | |
f.close() | |
url = "http://%s/upload.cgi" % host | |
payload = {'UPDIR':'/'} | |
r = requests.get(url, params=payload) | |
r.raise_for_status() | |
files = {'file':(fname, open(fpath,'rb'))} | |
r = requests.post(url, files=files) | |
r.raise_for_status() |
flashget.py
import requests
import encodings
import clipboard
host = "192.168.0.1"
fnane = "CLIP.TXT"
c = requests.get("http://%s/%s" % (host, fname)).content
t = unicode(c, 'shift_jis')
t = t.encode("utf-8")
clipboard.set(t.replace("\r\n", "\r"))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for Pythonista