Guest
Public paste!

Untitled

By: a guest | Aug 30th, 2010 | Syntax: None | Size: 0.81 KB | Hits: 84 | Expires: Never
Copy text to clipboard
  1. #!/usr/bin/python
  2.  
  3.  import sys, httplib, urllib
  4.  
  5.  api_domain = 'pastebin.com:80'
  6.  api_uri = '/api_public.php'
  7.  paste_expire_date = 'N'
  8.  paste_format = 'text'
  9.  
  10.  try:
  11.         paste_code = (' '.join(sys.stdin.readlines())).strip()
  12.  except:
  13.         paste_code = ''
  14.  
  15.  if paste_code == '':
  16.         print "You must give a content to past ;)"
  17.  else:
  18.         api_datas = urllib.urlencode({'paste_code': paste_code,'paste_expire_date': paste_expire_date, 'paste_format': paste_format})
  19.         headers = {'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain'}
  20.         http = httplib.HTTPConnection(api_domain)
  21.         http.request('POST', api_uri, api_datas, headers)
  22.         response = http.getresponse()
  23.         if response.status == 200:
  24.                 print response.read()
  25.         else:
  26.                 print 'Http request error: ', response.status, response.reason;
  27.  
  28.         http.close()
  29.  
  30.  sys.exit()