darsoarafa commited on
Commit
fd658ab
·
verified ·
1 Parent(s): e1e4e3b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from extract import take_webdata
3
+ from PIL import Image
4
+ from io import BytesIO
5
+
6
+ def main():
7
+ st.title("Website Content Exctractor")
8
+
9
+ # Get website URL from user input
10
+ url = st.text_input("Enter a URL:", "")
11
+ if st.button("Proceed"):
12
+ if not url:
13
+ st.warning("URL is empty.")
14
+ else:
15
+ visualize(url)
16
+
17
+
18
+ def visualize(url):
19
+ try:
20
+ # Fetch and display the website content
21
+ with st.spinner("loading website data ..."):
22
+ # innerHTML = get_innerHTML(url)
23
+ html_image, html_content = take_webdata(url)
24
+ st.subheader("Website title:")
25
+ if html_content:
26
+ st.info(html_content)
27
+ else:
28
+ st.error("Error: empty html content")
29
+ st.subheader("Website preview:")
30
+ if html_image:
31
+ st.image(html_image)
32
+ else:
33
+ st.error("Error: empty html preview")
34
+
35
+
36
+ except Exception as e:
37
+ st.error(f"Error: {e}")
38
+
39
+
40
+
41
+ if __name__ == "__main__":
42
+ main()