Created
February 26, 2021 11:47
-
-
Save subtra3t/b6e79ae854f56a79f7ecb927752905d2 to your computer and use it in GitHub Desktop.
Revisions
-
subtra3t created this gist
Feb 26, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ import urllib.request def create(url, format="simple", logstats=False): ascii_url = "" for c in url: if c in "1234567890qwertyuiopasdfghjklzxcvbnm.": ascii_url += c else: ascii_url += "%" + str(int(str(ord(c)), 16)) query_params = f"?format={format}&url={url}&logstats={1 if logstats else 0}" # Because unfortunately is.gd doesn't trust `Python-urllib/{your python version}`, though they have an API user_agent = { "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64)", } request = urllib.request.Request("https://is.gd/create.php" + query_params, None, user_agent) with urllib.request.urlopen(request) as response: return response.read().decode("utf-8")