Spaces:
Sleeping
Sleeping
Update app.py
#3
by chanraphone4 - opened
app.py
CHANGED
|
@@ -1,42 +1,20 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from
|
| 3 |
-
from PIL import Image
|
| 4 |
-
from io import BytesIO
|
| 5 |
|
| 6 |
-
|
| 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 |
-
|
| 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 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from playwright.sync_api import sync_playwright
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
st.title("π Web Browser ααΆααααα½αααααΎ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
url = st.text_input("αααα
αΌα Link αααααΆα:", "https://www.google.com")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
if st.button("αα
ααΆαααααααΆα"):
|
| 9 |
+
with sync_playwright() as p:
|
| 10 |
+
# ααΎα Browser ααΆαα
|
| 11 |
+
browser = p.chromium.launch(headless=True)
|
| 12 |
+
page = browser.new_page()
|
| 13 |
+
page.goto(url)
|
| 14 |
+
|
| 15 |
+
# ααααΌααααα αΆα
|
| 16 |
+
st.success(f"αααα»ααααα αΆααααααΆα: {url}")
|
| 17 |
+
screenshot = page.screenshot(full_page=False)
|
| 18 |
+
st.image(screenshot, caption="ααΌαααΆαα’αααααα")
|
| 19 |
+
|
| 20 |
+
browser.close()
|