Nishant Gour
Nishant Gour's Blog


Nishant Gour's Blog

URL Shortening with Python !

URL Shortening with Python !

Nishant Gour's photo
Nishant Gour
ยทMay 4, 2021ยท

1 min read

Play this article

We all know about Uniform Resource Locator (URL). Sometimes We want to send a URL/Link to someone. It creates unnecessary extra text in the URL which basically makes it difficult and irritating to manage them.

So today we are going to Implement a URL shortener program with the help of python.

We are going to use pyshortners. So what is pyshortners ?.

Pyshortners: A Python lib to wrap and consume the most used shorteners APIs.

We have to install this library inorder to use it.

installing pyshortners with pip command Install : pip install pyshortners

Using pyshortners library

import pyshorteners

URL = input("Enter The Url/Link: ")

short_URL = pyshorteners.Shortener()
result = short_URL.tinyurl.short(URL)


Now we will see the result


As you can see the URL is too big.

Let's Paste in our Program


Now you can see a TinyURL has been generated by our program. This is how pyshortners works in python.