mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-24 04:21:12 +00:00
35 lines
885 B
Python
35 lines
885 B
Python
|
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)
|
||
|
"""
|