File size: 1,590 Bytes
b6e91ad eb8f08c b6e91ad 1bbce87 b6e91ad 8c1f8f7 b6e91ad eb8f08c b6e91ad eb8f08c b6e91ad eb8f08c 7ebb52f dc9fb5d 984bb90 b6e91ad 984bb90 b6e91ad 984bb90 7ebb52f 744a624 7ebb52f 744a624 7ebb52f b6e91ad |
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 46 47 48 49 50 51 52 53 54 55 |
import streamlit as st
from extract import take_webdata, get_vehicle_info
from PIL import Image
from io import BytesIO
def main():
st.title("Website Content Exctractor")
# Get website URL from user input
url = st.text_input("Masukkan Nopol:", "")
if st.button("Proceed"):
if not url:
st.warning("Nopol kosong.")
else:
visualize(url)
def visualize(url):
try:
# Fetch and display the website content
with st.spinner("loading website data ..."):
# innerHTML = get_innerHTML(url)
# html_image, html_content = take_webdata(url)
html_image, html_content, data = get_vehicle_info(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")
data_kendaraan, total_tagihan, rincians_pkb, rincians_swd = data
st.json(
{
"data_kendaraan":data_kendaraan,
"rincian_tagihan":total_tagihan,
"rincian_pkb":[x for x in rincians_pkb if any(x.values())],
"rincian_swdkllj":[x for x in rincians_swd if any(x.values())]
}
)
except Exception as e:
st.error(f"Error: {e}")
if __name__ == "__main__":
main()
|