-
Notifications
You must be signed in to change notification settings - Fork 0
/
httrack.py
35 lines (26 loc) · 1.05 KB
/
httrack.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
29
30
31
32
33
34
35
import subprocess
import os
def mirror_website(url, output_directory):
try:
command = f"httrack {url} -O {output_directory}"
subprocess.run(command, check=True, shell=True)
print(f"Website mirrored successfully in {output_directory}")
except subprocess.CalledProcessError as e:
print(f"An error occurred while mirroring the website: {e}")
url = "https://www.evelyntan.net/"
output_directory = "C:\\Websites"
mirror_website(url, output_directory)
url_formatted = url.replace("https://", "").replace("/", "").strip()
html = []
for subdir, dirs, files in os.walk(output_directory):
if url_formatted in subdir:
for file in files:
if file.endswith(".html") or file.endswith(".htm"):
full_path = os.path.join(subdir, file)
html.append(full_path)
file_path = "html.txt"
with open(file_path, 'a') as file:
for path in html:
print(path)
file.write(path + "\n")
print(f"Paths of all HTML files have been saved to {file_path}")