Merge pull request #9 from priddhesh/master

Added URLShortener.py file
This commit is contained in:
Advaita Saha 2022-10-01 01:02:45 +05:30 committed by GitHub
commit 9c32ff9e77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

35
scripts/URLShortener.py Normal file
View File

@ -0,0 +1,35 @@
import pyshorteners
import argparse
def generateShortURL(URL):
shortener = pyshorteners.Shortener()
url = URL
shorten_url= shortener.tinyurl.short(url)
print("Shorten URL is: " + shorten_url)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("URL",type = str)
args = parser.parse_args()
generateShortURL(args.URL)
#Using bitly_api
"""
import bitly_api
import argparse
def generateShortURL(url):
access_token_ID = "" #ACCESS ID GENERATED FROM WEBSITE
connection = bitly_api.Connection(access_token= access_token_ID)
shorten_url = connection.shorten(url)
print("Shorten URL is: "shorten_url.get('url'))
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("URL",type = str)
args = parser.parse_args()
generateShortURL(args.URL)
"""