Skip to main content

Command Palette

Search for a command to run...

URL shortener in python

Updated
1 min readView as Markdown
URL shortener in python
N

It has now been seven years since I am exploring my ways in the world of New Age technology. In all these years, what is my favourite thing in the whole world? I would say my keyboard! If it’s a war, I got my code as the skill and my keyboard as the weapon. When I was a kid, I wondered what it would feel like to be a hacker. I kept feeding my curiosity in the bits and pieces. I was getting introduced with new things everyday and over time. All this passion has made me targeted towards my main objective, that is, to learn everything which is out there about computer. For now, I have got a good grip over Python, JavaScript, C and C++. I think the main reason for my motivation is that I strongly believe, if you keep your mind clear and devote yourself to pure learning, there will come a time when your own reality will get surrounded by your self-made uniqueness.

In this tutorial, we will learn how to shorten a URL using pyshorteners.

Explanation ✏

  1. First, we need to install pyshorteners command: pip install pyshorteners
  2. Then, import pyshorteners in your program
  3. Add a link which you need to shorten in my case (https://dx4iot.hashnode.dev/)
  4. Then finally print the URL

Code 👩‍💻

import pyshorteners
def shortURL():
    link = "https://techcosto.com/author/dx4iot/"
    print(pyshorteners.Shortener().clckru.short(link))
shortURL()

Output: https://clck.ru/VUyLY