Spaces:
Runtime error
Runtime error
Update app.py
Browse files123345678912 unmodified lines2223242525272627282930313432333414 unmodified lines49505155565253545556import streamlit as stimport requestsfrom bs4 import BeautifulSoupimport osimport urllibimport base64from bs4 import BeautifulSoup
EXCLUDED_FILES = ['app.py', 'requirements.txt', 'pre-requirements.txt', 'packages.txt', 'README.md','.gitattributes', "backup.py","Dockerfile"]
12 unmodified linesdef download_html_and_files(url): html_content = requests.get(url).text soup = BeautifulSoup(html_content, 'html.parser')
base_url = urllib.parse.urlunparse(urllib.parse.urlparse(url)._replace(path='', params='', query='', fragment=''))
for link in soup.find_all('a'): file_url = urllib.parse.urljoin(base_url, link.get('href')) local_filename = urllib.parse.urlparse(file_url).path.split('/')[-1] if local_filename: link['href'] = local_filename download_file(file_url, local_filename) with open("index.html", "w") as file: file.write(str(soup))
14 unmodified lines st.sidebar.markdown(get_download_link(file), unsafe_allow_html=True)
def main(): st.sidebar.title('Bulk Download Tool') url = st.sidebar.text_input('Please enter a URL to bulk download text and files') st.sidebar.title('Web Bulk Downloader') url = st.sidebar.text_input('Please enter a Web URL to bulk download text and files') if st.sidebar.button('📥 Get All the Content'): download_html_and_files(url) show_download_links()app.py+3-6