Mobile version of this page
Previous:
Python regular expression tester
Next:
Ruby and Python benchmarked
Announcing Smurl - a free URL compressor
Python regular expression tester
Next:
Ruby and Python benchmarked
Related blogs
parametrize_url() adding parameters to URLsAnnouncing Smurl - a free URL compressor
Related by category
Smurl from Python
22nd of September 2005
If you thought the Web Service example on the about page of Smurl.name was complicated, here's a much simpler version. I use this code on my very own site for the email notifications which will contain long URLs.
Feel free to steal this code into your own projects:
from urllib import urlopen, quote
# variable 'url' is defined elsewhere
if len(url) > 80:
url = urlopen('http://smurl.name/createSmurl?url=%s' % quote(url)).read()
# variable 'url' is defined elsewhere
if len(url) > 80:
url = urlopen('http://smurl.name/createSmurl?url=%s' % quote(url)).read()
Was that hard?







Save this page in del.icio.us
No