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
Autocomplete using PostgreSQL instead of Elasticsearch December 18, 2025 Python
Comparison of speed between gpt-5, gpt-5-mini, and gpt-5-nano December 15, 2025 Python
Using AI to rewrite blog post comments November 12, 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