File size: 1,154 Bytes
e2035ab 88584e6 e2035ab 88584e6 e2035ab 88584e6 e2035ab 88584e6 e2035ab 88584e6 e2035ab | 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 | 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
|