Untitled
By: a guest | Aug 30th, 2010 | Syntax:
None | Size: 0.81 KB | Hits: 84 | Expires: Never
#!/usr/bin/python
import sys, httplib, urllib
api_domain = 'pastebin.com:80'
api_uri = '/api_public.php'
paste_expire_date = 'N'
paste_format = 'text'
try:
paste_code = (' '.join(sys.stdin.readlines())).strip()
except:
paste_code = ''
if paste_code == '':
print "You must give a content to past ;)"
else:
api_datas = urllib.urlencode({'paste_code': paste_code,'paste_expire_date': paste_expire_date, 'paste_format': paste_format})
headers = {'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain'}
http = httplib.HTTPConnection(api_domain)
http.request('POST', api_uri, api_datas, headers)
response = http.getresponse()
if response.status == 200:
print response.read()
else:
print 'Http request error: ', response.status, response.reason;
http.close()
sys.exit()