gh / app.py
Starchik1's picture
Update app.py
88584e6 verified
import streamlit as st
import requests
from bs4 import BeautifulSoup
# Функция для выполнения запроса и получения HTML-страницы
def get_section_content(vin):
url = f"https://e-zipavto.com/search/index?SearchForm%5Boption%5D=&SearchForm%5Boption%5D=2&SearchForm%5Bsearch%5D={vin}"
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
# Находим секцию с id="mainContent"
main_content = soup.find('section', id='mainContent')
if main_content:
return main_content.prettify()
else:
return None
# Основное приложение Streamlit
st.title('Display Section from Web Page')
vin = st.text_input('Enter VIN', '4JGDF2EE4FA506008')
if st.button('Search'):
if vin:
section_content = get_section_content(vin)
if section_content:
st.write(section_content, unsafe_allow_html=True)
else:
st.write('Section not found or VIN not found.')
else:
st.write('Please enter a VIN.')
# Запуск командой в терминале: streamlit run app.py