File size: 1,236 Bytes
b6e91ad
1c971b9
984bb90
b6e91ad
1bbce87
b6e91ad
 
1c971b9
b6e91ad
 
 
 
 
 
 
 
 
 
 
 
1c971b9
 
 
 
 
984bb90
1c971b9
 
984bb90
 
 
1c971b9
 
 
984bb90
 
b6e91ad
1c971b9
b6e91ad
 
 
 
 
 
1c971b9
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
36
37
38
39
40
41
42
43
44
45
import streamlit as st
import time
from extract import take_webdata
from PIL import Image
from io import BytesIO

def main():
    st.title("Website Content Extractor")
    
    # Get website URL from user input
    url = st.text_input("Enter a URL:", "")
    if st.button("Proceed"):
        if not url:
            st.warning("URL is empty.")
        else:
            visualize(url)
  

def visualize(url):  
    try:
        # Add a 10-second delay before fetching the website data
        with st.spinner("Loading website data... Please wait..."):
            time.sleep(10)  # Wait for 10 seconds before proceeding
            
            # Fetch and display the website content
            html_image, html_content = take_webdata(url)
            
            st.subheader("Website Title:")
            if html_content:
                st.info(html_content)
            else:
                st.error("Error: empty HTML content.")
            
            st.subheader("Website Preview:")
            if html_image:
                st.image(html_image)
            else:
                st.error("Error: empty HTML preview.")
    
    except Exception as e:
        st.error(f"Error: {e}")


if __name__ == "__main__":
    main()