Skip to content

Instantly share code, notes, and snippets.

@vkrm26
Created April 8, 2021 10:44
Show Gist options
  • Save vkrm26/e293637cf229035183cec466440b5500 to your computer and use it in GitHub Desktop.
Save vkrm26/e293637cf229035183cec466440b5500 to your computer and use it in GitHub Desktop.
Bintray JCenter is sunsetting on 1st May 2021, so it's great to download all older artifacts in the correct order and hierarchy. use below script.
import requests
import os
from bs4 import BeautifulSoup
def checkChild(parentdir, url):
r = requests.get(url)
if r.headers.get('Content-Type') != 'text/html;charset=UTF-8':
file = open(parentdir, "wb")
file.write(r.content)
return
soup = BeautifulSoup(r.content, 'lxml')
for row in soup.find_all('a'):
href = row.get('href')
path = os.path.join(parentdir, href)
if path.find(str(".jar")) == -1 and path.find(str(".aar")) == -1 and path.find(str(".pom")) == -1 and path.find(str(".xml")) == -1 and path.find(str(".zip")) == -1:
os.makedirs(path)
checkChild(path, url + str(href))
# Replace below from your own bintray url
URL = "https://abc.bintray.com/abc/artifact_id"
checkChild(os.getcwd(), URL)
beautifulsoup4
requests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment