This commit is contained in:
Valentin CZERYBA 2023-03-08 22:05:25 +01:00
parent 21d24d638d
commit 77e61ef571

View File

@ -123,12 +123,12 @@ def downloadPage(webpage, backup_dir, logger):
filePageWeb = path_web[len(path_web)-1] filePageWeb = path_web[len(path_web)-1]
path_web.pop(len(path_web)-1) path_web.pop(len(path_web)-1)
dir_page_web = "/".join(path_web) dir_page_web = "/".join(path_web)
mkdirPath("{0}/{1}".format(backup_dir, dir_page_web), logger) mkdirPath("{0}/{1}/{2}".format(backup_dir, o.netloc, dir_page_web), logger)
r = requests.get(webpage[i]) r = requests.get(webpage[i])
if r.status_code == 200: if r.status_code == 200:
fileDownload = "{0}/index.html".format(backup_dir) fileDownload = "{0}/{1}/index.html".format(backup_dir, o.netloc)
if len(dir_page_web) > 0 and len(filePageWeb) > 0: if len(dir_page_web) > 0 and len(filePageWeb) > 0:
fileDownload = "{0}{1}/{2}".format(backup_dir, dir_page_web, filePageWeb) fileDownload = "{0}/{1}{2}/{3}".format(backup_dir, o.netloc, dir_page_web, filePageWeb)
logger.info("{0}/{1} : {2}".format(i+1, len(webpage), fileDownload)) logger.info("{0}/{1} : {2}".format(i+1, len(webpage), fileDownload))
open(fileDownload, "wb").write(r.content) open(fileDownload, "wb").write(r.content)