Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3.3
- import os.path
- import urllib.request
- import zipfile
- from bs4 import BeautifulSoup
- import requests
- import re
- import os
- TMP_DIR = "C:\\tmp"
- DOWNLOADS_DIR_UNZIPPED = "C:\\Games\\WOROR\\Interface\\AddOns"
- url = 'https://tools.idrinth.de/addons/'
- if not os.path.exists(TMP_DIR):
- os.makedirs(TMP_DIR)
- reqs = requests.get(url)
- soup = BeautifulSoup(reqs.text, 'html.parser')
- urls = []
- links = [ 'https://tools.idrinth.de/' + x.get('href') for x in soup.find_all(href=re.compile("/download/"))]
- for link in links:
- link = link.strip()
- print('Link: ' + link)
- name = link.rsplit('/', 4)[-4]
- filename = os.path.join(TMP_DIR, name)
- if not os.path.isfile(filename):
- try:
- urllib.request.urlretrieve(link, filename + '.zip')
- with zipfile.ZipFile(filename + '.zip', 'r') as zip_ref:
- print('Downloading: ' + DOWNLOADS_DIR_UNZIPPED + '/' + name)
- zip_ref.extractall(DOWNLOADS_DIR_UNZIPPED)
- except Exception as inst:
- print(inst)
- print(' Encountered unknown error. Continuing.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement