Created
October 13, 2016 11:01
-
-
Save alex-bender/f78b731ba18a84183329df92df1cefcb to your computer and use it in GitHub Desktop.
paste to hastebin
This file contains hidden or 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
#!/usr/bin/python | |
import urllib2 | |
import os | |
import json | |
URL = 'http://hastebin.com/documents' | |
def run(*args): | |
if args: | |
content = [open(x).read() for x in args] | |
extensions = [os.path.splitext(x)[1] for x in args] | |
else: | |
content = [sys.stdin.read()] | |
extensions = [None] | |
for i, each in enumerate(content): | |
req = urllib2.Request(URL, each) | |
response = urllib2.urlopen(req) | |
the_page = response.read() | |
key = json.loads(the_page)['key'] | |
url = "http://hastebin.com/%s" % key | |
if extensions[i]: | |
url += extensions[i] | |
print url | |
if __name__ == '__main__': | |
import sys | |
sys.exit(run(*sys.argv[1:])) |
Author
alex-bender
commented
Oct 13, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment