TechieYan Technologies

Making URL Shortener using Python

Abstract

Navigating and sharing long URLs is a pain. The cause behind see you later URLs is the wide variety of trackers in a hyperlink, loaded up content material (more than one directories) of heavy web sites, and so on. All of us use URL shorteners for that cause to shorten the lengthy URLs to a few characters, which makes them less complicated to share and navigate through and also look easy and elegant.

However, have you ever been puzzled about coding a URL shortener yourself? In this education, we are able to explain the manner of coding a URL shortener in Python with very easy steps.

There are plenty of different methods using which you may shorten a URL, the majority of them requiring API

Libraries:

Pyshorteners: pyshorteners is a Python lib to help you short and expand urls using the most famous URL Shorteners availables. To install this library use the below command

pip install pyshorteners

Code Description & Execution

Program Methodology

Firstly we need to import the required library. We take input from the person , we should have completed the inputting component later in our code, but that could allow us to change the primary/permanent structure of the code, which we are going to exchange for each URL shortener’s APIs.

Now we initialize the pyshortener library’s elegance object to begin shortening our URLs.

Now, as we’ve got initialized our library, we will start with the shortening of the URLs.

You’re required to bypass the name alongside the region of the PDF if it’s no longer inside the equal listing because of the python script.

In the output, we get the shortened URL

How to Execute?

Note: Make sure you have added path while installing the software’s.

https://techieyantechnologies.com/2022/07/how-to-install-anaconda/

https://techieyantechnologies.com/2022/06/get-started-with-creating-new-environment-in-anaconda-configuring-jupyter-notebook-and-installing-libraries-using-requirements-txt-2/

  1. Install the prerequisites/software’s required to execute the code from reading the above blog which is provided in the link above.
  2. Press windows key and type in anaconda prompt a terminal opens up.
  3. Go to the directory where your requirement.txt file is present, not just requirement.txt, if you want to execute any .py or .ipynb files, you need to go to that specific folder or path, where they are saved.
  4. <<directory of your file:>>. E.g., If my file is in d drive, then.
  5. Type d:
  1. cd d:\License-Plate-Recognition-main    #CHANGE PATH AS PER YOUR PROJECT, THIS IS JUST AN EXAMPLE

          7. If your project is in c drive, you can ignore step 4 and go with step 5

          8. Run pip install -r requirements.txt or conda install requirements.txt (Requirements.txt is a text file consisting of all the necessary libraries required for executing this python file. If it gives any error while installing libraries, you might need to install them individually.), example: pip install “module_name”.

Results

Issues Faced

  1. We might face an issue while installing specific libraries, in this case, you might need to install the libraires manually. Example: pip install “module_name/library” i.e., pip install pandas
  2. Make sure you have the latest or specific version of python, since sometimes it might cause version mismatch.

Click Here To Download This Code And Associated File.

Conclusion:

That’s It for this project. Hope you’ve got found out approximately the shortening of URLs and the way you may create a URL shortener the use of Python

+91 7075575787