Created
February 26, 2021 11:47
-
-
Save subtra3t/b6e79ae854f56a79f7ecb927752905d2 to your computer and use it in GitHub Desktop.
is.gd python
This file contains 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 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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment