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
URL.
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
print(shorter_url(
"https://thecyberblogs.com"))


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