22 September 2005 1 comment Python
This blog post is 17 years old! Most likely, its content is outdated. Especially if it's technical.
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?
- Previous:
- Python regular expression tester 19 September 2005
- Next:
- Ruby and Python benchmarked 25 September 2005
- Related by category:
- Best practice with retries with requests 19 April 2017 Python
- How much faster is Redis at storing a blob of JSON compared to PostgreSQL? 28 September 2019 Python
- Fastest way to find out if a file exists in S3 (with boto3) 16 June 2017 Python
- Interesting float/int casting in Python 25 April 2006 Python
- Fastest way to unzip a zip file in Python 31 January 2018 Python
- Related by keyword:
- parametrize_url() adding parameters to URLs 14 January 2005
- Announcing Smurl - a free URL compressor 7 September 2005
No