Advertisement
Guest User

/r/dailyprogrammer #28 [difficult]

a guest
Mar 21st, 2012
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. import httplib, urllib, sys
  2.  
  3. def post_paste(body, dev_key = 'log in to pastebin and go to http://pastebin.com/api#1 to get your dev key', title = '', private = 1, user_key = ''):
  4.     params = urllib.urlencode({'api_option' : 'paste', 'api_dev_key': dev_key, 'api_paste_private' : private, 'api_paste_name': title, 'api_paste_code' : body})
  5.     headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
  6.     conn = httplib.HTTPConnection("www.pastebin.com")
  7.     conn.request("POST", "/api/api_post.php", params, headers)
  8.     response = conn.getresponse()
  9.     data = response.read()
  10.     print data
  11.     conn.close()
  12.  
  13. paste_body = sys.stdin.read()
  14. if(paste_body == ""):
  15.     quit()
  16. post_paste(paste_body)
  17.  
  18. #fractals_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement