jonathanjordan21/selenium_web_scrape
0
1import streamlit as st2from extract import take_webdata, get_vehicle_info3from PIL import Image4from io import BytesIO5 6def main():7 st.title("Website Content Exctractor")8 9 # Get website URL from user input10 url = st.text_input("Masukkan Nopol:", "")11 if st.button("Proceed"):12 if not url:13 st.warning("Nopol kosong.")14 else:15 visualize(url)16 17 18def visualize(url): 19 try:20 # Fetch and display the website content21 with st.spinner("loading website data ..."):22 # innerHTML = get_innerHTML(url)23 # html_image, html_content = take_webdata(url)24 html_image, html_content, data = get_vehicle_info(url)25 st.subheader("Website title:")26 if html_content:27 st.info(html_content)28 else:29 st.error("Error: empty html content")30 st.subheader("Website preview:")31 if html_image:32 st.image(html_image)33 else:34 st.error("Error: empty html preview")35 36 data_kendaraan, total_tagihan, rincians_pkb, rincians_swd = data37 38 st.json(39 {40 "data_kendaraan":data_kendaraan,41 "rincian_tagihan":total_tagihan,42 "rincian_pkb":[x for x in rincians_pkb if any(x.values())],43 "rincian_swdkllj":[x for x in rincians_swd if any(x.values())]44 }45 )46 47 48 except Exception as e:49 st.error(f"Error: {e}")50 51 52 53if __name__ == "__main__":54 main()55 