Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,11 +21,13 @@ def download_html_and_files(url):
|
|
21 |
for link in soup.find_all('a'):
|
22 |
file_url = urllib.parse.urljoin(base_url, link.get('href'))
|
23 |
local_filename = urllib.parse.urlparse(file_url).path.split('/')[-1]
|
24 |
-
|
25 |
-
|
|
|
26 |
|
27 |
with open("index.html", "w") as file:
|
28 |
file.write(str(soup))
|
|
|
29 |
|
30 |
def list_files(directory_path='.'):
|
31 |
return [f for f in os.listdir(directory_path) if os.path.isfile(os.path.join(directory_path, f))]
|
|
|
21 |
for link in soup.find_all('a'):
|
22 |
file_url = urllib.parse.urljoin(base_url, link.get('href'))
|
23 |
local_filename = urllib.parse.urlparse(file_url).path.split('/')[-1]
|
24 |
+
if local_filename: # add this line
|
25 |
+
link['href'] = local_filename
|
26 |
+
download_file(file_url, local_filename)
|
27 |
|
28 |
with open("index.html", "w") as file:
|
29 |
file.write(str(soup))
|
30 |
+
|
31 |
|
32 |
def list_files(directory_path='.'):
|
33 |
return [f for f in os.listdir(directory_path) if os.path.isfile(os.path.join(directory_path, f))]
|