Spaces:
Running
Running
import streamlit as st | |
""" | |
## Web scraping on Streamlit Cloud with Selenium | |
[](https://github.com/snehankekre/streamlit-selenium-chrome/) | |
This is a minimal, reproducible example of how to scrape the web with Selenium and Chrome on Streamlit's Community Cloud. | |
Fork this repo, and edit `/streamlit_app.py` to customize this app to your heart's desire. :heart: | |
""" | |
with st.echo(): | |
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
from selenium.webdriver.chrome.service import Service | |
from webdriver_manager.chrome import ChromeDriverManager | |
from webdriver_manager.core.os_manager import ChromeType | |
def get_driver(): | |
return webdriver.Chrome( | |
service=Service( | |
ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install() | |
), | |
options=options, | |
) | |
options = Options() | |
options.add_argument("--disable-gpu") | |
options.add_argument("--headless") | |
driver = get_driver() | |
driver.get("http://example.com") | |
st.code(driver.page_source) | |