Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- .devcontainer/devcontainer.json +33 -0
- .gitignore +2 -0
- packages.txt +1 -0
- requirements.txt +3 -0
- streamlit_app.py +36 -0
.devcontainer/devcontainer.json
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "Python 3",
|
3 |
+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
4 |
+
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
|
5 |
+
"customizations": {
|
6 |
+
"codespaces": {
|
7 |
+
"openFiles": [
|
8 |
+
"README.md",
|
9 |
+
"streamlit_app.py"
|
10 |
+
]
|
11 |
+
},
|
12 |
+
"vscode": {
|
13 |
+
"settings": {},
|
14 |
+
"extensions": [
|
15 |
+
"ms-python.python",
|
16 |
+
"ms-python.vscode-pylance"
|
17 |
+
]
|
18 |
+
}
|
19 |
+
},
|
20 |
+
"updateContentCommand": "[ -f packages.txt ] && sudo apt update && sudo apt upgrade -y && sudo xargs apt install -y <packages.txt; [ -f requirements.txt ] && pip3 install --user -r requirements.txt; pip3 install --user streamlit; echo '✅ Packages installed and Requirements met'",
|
21 |
+
"postAttachCommand": {
|
22 |
+
"server": "streamlit run streamlit_app.py --server.enableCORS false --server.enableXsrfProtection false"
|
23 |
+
},
|
24 |
+
"portsAttributes": {
|
25 |
+
"8501": {
|
26 |
+
"label": "Application",
|
27 |
+
"onAutoForward": "openPreview"
|
28 |
+
}
|
29 |
+
},
|
30 |
+
"forwardPorts": [
|
31 |
+
8501
|
32 |
+
]
|
33 |
+
}
|
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
.venv/
|
2 |
+
.streamlit/secrets.toml
|
packages.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
chromium
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
seleniumbase
|
3 |
+
webdriver-manager
|
streamlit_app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
"""
|
4 |
+
## Web scraping on Streamlit Cloud with Selenium
|
5 |
+
|
6 |
+
[](https://github.com/snehankekre/streamlit-selenium-chrome/)
|
7 |
+
|
8 |
+
This is a minimal, reproducible example of how to scrape the web with Selenium and Chrome on Streamlit's Community Cloud.
|
9 |
+
|
10 |
+
Fork this repo, and edit `/streamlit_app.py` to customize this app to your heart's desire. :heart:
|
11 |
+
"""
|
12 |
+
|
13 |
+
with st.echo():
|
14 |
+
from selenium import webdriver
|
15 |
+
from selenium.webdriver.chrome.options import Options
|
16 |
+
from selenium.webdriver.chrome.service import Service
|
17 |
+
from webdriver_manager.chrome import ChromeDriverManager
|
18 |
+
from webdriver_manager.core.os_manager import ChromeType
|
19 |
+
|
20 |
+
@st.cache_resource
|
21 |
+
def get_driver():
|
22 |
+
return webdriver.Chrome(
|
23 |
+
service=Service(
|
24 |
+
ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()
|
25 |
+
),
|
26 |
+
options=options,
|
27 |
+
)
|
28 |
+
|
29 |
+
options = Options()
|
30 |
+
options.add_argument("--disable-gpu")
|
31 |
+
options.add_argument("--headless")
|
32 |
+
|
33 |
+
driver = get_driver()
|
34 |
+
driver.get("http://example.com")
|
35 |
+
|
36 |
+
st.code(driver.page_source)
|