Is a Python lib to wrap and consume the most used shorteners APIs. Many people use because is fast and anonymous.
Installing
pip install pyshorteners
Coding
import pyshorteners
def shorter(link):
#create object
short = pyshorteners.Shortener()
short_link = short.tinyurl.short(link)
return short_link
url = input("URL: ")
final = shorter(url)
print(f"Shortened Link is {final}")
#append orginal and final url in a .txt file
file_object = open('urls.txt', 'a')
file_object.write("\n---------------------------------------------\nOriginal Url: " + url + "\nShortened Link is: " + final +"\n")
print("Saved in urls.txt")
run the code
python short_url.py
Output
URL: https://peakd.com/c/hive-169321/created
Shortened Link is https://tinyurl.com/yf7jaf46
Saved in urls.txt
Text File (urls.txt)
---------------------------------------------
Original Url: https://peakd.com/c/hive-169321/created
Shortened Link is: https://tinyurl.com/yf7jaf46
I code this just for fun, now I'm creating a lot of content on blockchain dapps and web development so I think this code could be very useful for people who don't use interfaces and prefer to do everything in a python script.