All pastes #738483 Raw Edit

Something

public text v1 · immutable
·published 2007-10-16 11:06 UTC
rendered paste body
def MakeMeTiny(url):
        #url = url[1:]
       
      # print url
        SEARCH_BASE_URL = "/create.php"
        #params = urllib.urlencode({'url': "+".join(url)})
        #print params
        headers = { 'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' }
        conn = httplib.HTTPConnection("tinyurl.com")
        url = SEARCH_BASE_URL+"?"+"url="+"".join(url)
       # print url
        conn.request("GET", url, {}, headers)
        response = conn.getresponse()
        data = response.read()
        myparser = HTMLParser()
        myparser.parse(data)
        #sendmsg(self.chan,'Tiny? %s' % (myparser.get_hyperlinks()[17]))
        conn.close()
        return myparser.get_hyperlinks()[17]