Created
October 23, 2012 04:21
-
-
Save foreigner92/3936625 to your computer and use it in GitHub Desktop.
Python Pastebin Scriot
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
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
error " print url "