Created
November 13, 2022 13:17
-
-
Save anir0y/5d7c8b6460da82134eef86dbb61af891 to your computer and use it in GitHub Desktop.
Script to create short URL using tiny.url API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
banner=""" | |
=^..^= | |
==> created by @anir0y | |
[+] we use tinyurl to create short URL | |
[+] reach me twitter: @anir0y | |
""" | |
print(banner) | |
inputurl=input("Enter Long URl and we will short it out: ") | |
headers = { | |
'accept': 'application/json', | |
# Already added when you pass json= but not when you pass data= | |
# 'Content-Type': 'application/json', | |
} | |
params = { | |
'api_token': 'YOUR_TOKEN_HERE', | |
} | |
json_data = { | |
'url': inputurl, | |
'domain': 'tiny.one', # you can change it to your domain(paid/free) | |
} | |
response = requests.post('https://api.tinyurl.com/create', params=params, headers=headers, json=json_data) | |
# parsing output | |
response = (response.text) | |
jsonblob= json.loads(response) | |
tinyurl=(jsonblob['data']['tiny_url']) | |
fullurl=(jsonblob['data']['url']) | |
# print output | |
print(banner) | |
print (f"Hey, your Long Boi URL: {fullurl}") | |
print (f" now shortboi url {tinyurl}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fuck yeah thats great