|
import streamlit as st |
|
from extract import extract_data |
|
import pandas as pd |
|
|
|
def main(): |
|
|
|
css = """ |
|
<style> |
|
h1#pycaro { |
|
text-align: center; |
|
color: #f85149; |
|
} |
|
h3 { |
|
color: #df6f6a; |
|
font-weight: 100; |
|
font-style: italic; |
|
font-size: large; |
|
} |
|
h3 a { |
|
color: white; |
|
font-weight: 100; |
|
font-style: italic; |
|
font-size: large; |
|
} |
|
td:nth-child(1) { |
|
white-space: nowrap; |
|
} |
|
th { |
|
text-align: left; |
|
font-weight: 300; |
|
color: #df6f6a; |
|
} |
|
table { |
|
width: 100%; |
|
border-collapse: collapse; |
|
} |
|
</style> |
|
""" |
|
|
|
st.markdown(css, unsafe_allow_html=True) |
|
|
|
|
|
st.title("PyCARO", anchor="pycaro") |
|
|
|
|
|
search_type = st.selectbox("Selecciona el tipo de b煤squeda", ["Dominio", "URL"]) |
|
|
|
|
|
input_label = "Introduce la URL del dominio" if search_type == "Dominio" else "Introduce la URL" |
|
user_input = st.text_input(input_label, "") |
|
|
|
if st.button("馃攷"): |
|
if not user_input: |
|
st.warning("No has introducido ninguna URL") |
|
else: |
|
mode = "domain" if search_type == "Dominio" else "url" |
|
visualize(user_input, mode) |
|
|
|
def visualize(user_input, mode): |
|
try: |
|
|
|
with st.spinner("Cargando datos del sitio web ..."): |
|
data = extract_data(user_input, mode) |
|
|
|
if data: |
|
st.subheader(f"Resultados para {user_input}") |
|
df = pd.DataFrame(data) |
|
|
|
|
|
if "脷ltima actualizaci贸n" in df.columns: |
|
df = df.drop(columns=["脷ltima actualizaci贸n"]) |
|
|
|
|
|
html_table = df.to_html(index=False, escape=False, border=0) |
|
st.markdown(html_table, unsafe_allow_html=True) |
|
else: |
|
st.error("No se encontraron datos") |
|
|
|
|
|
except Exception as e: |
|
st.error(f"Error: {e}") |
|
|
|
if __name__ == "__main__": |
|
main() |