URL Shortening with Python !

URL Shortening with Python !

ยท

1 min read

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)
print(result)

code.PNG

Now we will see the result

google.PNG

As you can see the URL is too big.

Let's Paste in our Program

image.png

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