Created
September 25, 2018 21:59
-
-
Save GarnetSunset/2dc813c4a618fac3384ca1158aabb070 to your computer and use it in GitHub Desktop.
Yikes!
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 json, os, requests | |
cwd = os.getcwd() | |
try: | |
input = raw_input | |
except NameError: | |
pass | |
raw = input("Please insert the landing page of the repo e.g. https://github.com/gorhill/uBlock \n>") | |
fixed = raw.replace("https://github.com/", "") | |
headers = requests.utils.default_headers() | |
headers.update( | |
{ | |
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36', | |
} | |
) | |
uBlock = requests.get('https://api.github.com/repos/'+fixed+'/releases/latest', headers=headers) | |
jsonVer = uBlock.content | |
jsonLoad = json.loads(jsonVer) | |
downloadLink = jsonLoad['assets'][0]['browser_download_url'] | |
download = requests.get(downloadLink, allow_redirects=True) | |
slashLoc = downloadLink.rfind('/') | |
fileName = downloadLink[slashLoc+1:] | |
open(fileName,'wb').write(download.content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment