Hi,
Welcome to PyTechTip. In this blog we are going to create a URL shortener with python. This is a easy project so let's get started.
1. Install the required modules. Here we are going to use pyshorteners module. So first install it.
Command: pip install pyshorteners
2. import the module.
Command: import pyshorteners
3. Get the Long URL from the User by Input Function.
Command: long_url = input("Enter you Long URL:")
4. Create a object for shortener.
Command: shortener = pyshorteners.Shortener()
5. After we Created the object, we can shorten our URL.
Command: short_url = shortener.tinyurl.short(long_url)
Note: Here we are using TinyUrl Service for our convenience.
6. Now we can print the shortened URL to the user by print function.
Command: print("Shortened URL is: " + short_url)
That concludes our session. Please run the code and test the URL shortener.
I hope you've learned something new today. Let's reconvene in the next tutorial.
Goodbye.