How to create URL Shortner with Python ?

How to create URL Shortner with Python ?

How to create URL Shortner with Python ?

In this artical we are going to see how to create a URL shortner in python using pyshorteners.

Most of us have used programs that generate short URLs. Python has a library called pyshorteners used to shorten a URL. First install it using pip:

pip install pyshorteners

Once you install it, you can import it into your script. The function below demonstrates how we can use pyshorteners. We pass a very long URL to the function, and it returns a short

import pyshorteners

def shorter_url(s: str):

      # Iniatialize the shortener

      pys = pyshorteners.Shortener()

      # Using the tinyurl to shorten

      short_url = pys.tinyurl.short(s)

      return 'Short url is', short_url


How to create URL Shortner with Python ?

Now you could see the output, this is the shorten URL.

Take a look at this courses on python for beginners ....

3484068 ef53 3show?id=o689U4nBeH4&bids=1060092
3737494 bd5bshow?id=o689U4nBeH4&bids=1060092
2450640 8d11 6show?id=o689U4nBeH4&bids=1060092
Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *