rendered paste bodyimport urllib2import redef paste(content, description="", name="", expiry="", type="raw"): TYPES = [ "raw", "asterisk", "c", "cpp", "php", "perl", "java", "vb", "csharp", "ruby", "python", "pascal", "mirc", "pli", "xml", "sql", "scheme", "ascript", "ada", "apache", "nasm", "asp", "bash", "css", "delphi", "html", "js", "lisp", "lua", "asm", "objc", "vbnet" ] POSTDATA = "content=%(content)s&description=%(description)s&type=%(type)s&expiry=%(expiry)s&name=%(name)s&save=0&s=Submit+Post" URL = "http://en.pastebin.ca/index.php" URL_PATTERN = re.compile('http://en.pastebin.ca/\d+') payload = POSTDATA % { "content" : urllib.quote_plus(content), "description" : urllib.quote_plus(description), "type" : TYPES.index(type)+1, "expiry" : urllib.quote_plus(expiry), "name" : urllib.quote_plus(name) } req = urllib2.Request(URL, payload, { "Referer": "http://en.pastebin.ca/", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050813 Epiphany/1.7.6", "Accept-Language": "en", "Accept-Charset": "utf-8", }) html = urllib2.urlopen(req).read() stuff = re.search('content=["]7;([^"]*)', html, re.MULTILINE) return stuff.group(1)def paste_file(fname): f = open(fname) contents = f.read() f.close() return paste(contents)print paste_file("pb.py")