Skip to content

Instantly share code, notes, and snippets.

@GarnetSunset
Created September 25, 2018 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GarnetSunset/2dc813c4a618fac3384ca1158aabb070 to your computer and use it in GitHub Desktop.
Save GarnetSunset/2dc813c4a618fac3384ca1158aabb070 to your computer and use it in GitHub Desktop.
Yikes!
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