Skip to main content

Ralsina.Me — Roberto Alsina's website

Using TinyURL in python

Is­n't this neat?

import urllib

def makeTiny(url):

  url='http://tinyurl.com/api-create.php?'+urllib.urlencode({'url':url})
  return urllib.urlopen(url).read()

>>> makeTiny('http://www.kde.org')
'http://tinyurl.com/3cnthx'

Comments

Comments powered by Disqus