From 58d57fe25b53b1720caf1dc791072943e94ab576 Mon Sep 17 00:00:00 2001 From: Hipstercat Date: Mon, 29 Jul 2019 17:18:49 +0200 Subject: [PATCH] Initial commit --- main.py | 39 +++++++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 2 files changed, 40 insertions(+) create mode 100644 main.py create mode 100644 requirements.txt diff --git a/main.py b/main.py new file mode 100644 index 0000000..fa7432a --- /dev/null +++ b/main.py @@ -0,0 +1,39 @@ +import requests +import re + + +def download_maps_in_url(url): + headers = {"Referer": "https://www.giantswd.org/index.php?file=1"} + reg = r"(?i)download\.php\?offsite=0&id=\d+&d=gmmmaps\/.*?.gck" + body = requests.get(url).text + maps = re.findall(reg, body) + for map_url in maps: + map_name = re.search(r'(?i)\/(.*?).gck', map_url).group()[1:] + print("Downloading "+map_name+" (https://giantswd.org/"+map_url+")") + r = requests.get("https://giantswd.org/"+map_url, allow_redirects=True, headers=headers) + open(map_name, 'wb').write(r.content) + if not maps: + raise Exception("No map found at this url: "+url) + + +def download_maps(): + page = 1 + + while True: + try: + url = "https://www.giantswd.org/?page=" + str(page) + "&file=1&search_id=&search_name=&search_author=&search_type=&search_db=Maps&sort=&sort_order=&result_per_page=10&Submit=Search" + print("Fetching "+url) + download_maps_in_url(url) + page += 1 + except Exception: + print("Done") + return + + +def main(): + download_maps() + # download_tools(): TBD + + +if __name__ == "__main__": + main() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..663bd1f --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests \ No newline at end of file