import streamlit as st from bs4 import BeautifulSoup def clean_bookmarks(html_content): soup = BeautifulSoup(html_content, 'html.parser') links = soup.find_all('a') cleaned_html = '\n' for link in links: href = link.get('href') anchor_name = link.text.strip() cleaned_html += f'{anchor_name}
\n' cleaned_html += '' return cleaned_html def main(): st.title('Bookmark File Cleaner') uploaded_file = st.file_uploader('Choose an HTML bookmark file', type=['html']) if uploaded_file is not None: html_content = uploaded_file.read().decode('utf-8') cleaned_html = clean_bookmarks(html_content) st.subheader('Cleaned Bookmarks') st.text_area('Output HTML', value=cleaned_html, height=400) output_file = 'cleaned_bookmarks.html' with open(output_file, 'w') as f: f.write(cleaned_html) st.download_button('Download Cleaned Bookmarks', cleaned_html, file_name=output_file) if __name__ == '__main__': main()