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()

Was that hard?

Comments

Tim Knapp

No

Your email will never ever be published.

Previous:
Python regular expression tester September 19, 2005 Python
Next:
Ruby and Python benchmarked September 25, 2005 Python
Related by category:
A Python dict that can report which keys you did not use June 12, 2025 Python
Faster way to sum an integer series in Python August 28, 2025 Python
Combining Django signals with in-memory LRU cache August 9, 2025 Python
Native connection pooling in Django 5 with PostgreSQL June 25, 2025 Python
Related by keyword:
Announcing Smurl - a free URL compressor September 7, 2005 Zope
parametrize_url() adding parameters to URLs January 14, 2005 Python