-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_srtm_hgt_files.py
28 lines (22 loc) · 1.12 KB
/
get_srtm_hgt_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
from bs4 import BeautifulSoup, SoupStrainer
import requests
for url, path in [("http://viewfinderpanoramas.org/Coverage%20map%20viewfinderpanoramas_org3.htm",
"/media/ronny/Backup500GB/srtm/3/"),
("http://viewfinderpanoramas.org/Coverage%20map%20viewfinderpanoramas_org1.htm",
"/media/ronny/Backup500GB/srtm/1/")]:
page = requests.get(url)
data = page.text
soup = BeautifulSoup(data)
os.chdir(path)
for link in soup.find_all(href=True):
lname = link.get('href')
fname = lname.rsplit("/", 1)[-1]
if not os.path.exists(fname) and not fname.endswith(".html") and not len(fname) < 3:
print(f"will download {fname} from {lname}")
#file_name = wget.download(site_url)
os.system(f"wget {lname}")
os.system(f"unzip {fname} && rm {fname} && touch {fname}") # create the empty zip file after extraction to not download again
fname_new = fname.replace('.zip', '/*')
os.system(f"mv {fname_new} . && rm -r {fname_new[:-1]}")
print("finished")