awacke1 commited on
Commit
a6f9b25
·
1 Parent(s): 6e3c7a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
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
- link['href'] = local_filename
25
- download_file(file_url, local_filename)
 
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))]