Initial commit
This commit is contained in:
commit
58d57fe25b
39
main.py
Normal file
39
main.py
Normal 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
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
requests
|
Loading…
Reference in New Issue
Block a user