Download app.py from Starchik1/gh: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/spaces/Starchik1/gh/resolve/main/app.py
- Command line
-
hf download hf://spaces/Starchik1/gh/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Starchik1/gh/resolve/main/app.py
1.15 kB
| 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 | |