Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Python Pastebin Scriot
import urllib
import sys
import re
if len(sys.argv) < 2:
#print usage()
sys.exit()
def getName():
name = sys.argv[1]
m = re.match(r"(?P<name>[\w\S]+)\.(?P<ext>\w+)", name)
name = m.group(1)
return name
# PARAMS
dev_key = '#################################'
user_key = '###############################'
paste_name = getName()
if len(sys.argv) == 3:
if sys.argv[2] == 'anon':
user_key = ''
# PARAMS
f = open(sys.argv[1], 'r')
data = f.read()
pastebin_vars = {'api_dev_key': dev_key,
'api_option': 'paste', 'api_paste_code': data,
'api_user_key': user_key,
'api_paste_name': paste_name}
response = urllib.urlopen('http://pastebin.com/api/api_post.php',
urllib.urlencode(pastebin_vars))
url = response.read()
print url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment