Initial commit

This commit is contained in:
Amazed 2019-07-29 17:18:49 +02:00
commit 58d57fe25b
2 changed files with 40 additions and 0 deletions

39
main.py Normal file
View File

@ -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()

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
requests