Skip to content

Commit 4662042

Browse files
committed
feat: export
1 parent 76817fa commit 4662042

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

backend/apps/datasource/api/export.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
# Author: Junjun
22
# Date: 2025/6/24
33

4+
import tempfile
45
import time
56

67
from fastapi import APIRouter
78
from selenium import webdriver
9+
from selenium.webdriver.chrome.options import Options
10+
from selenium.webdriver.chrome.service import Service
811
from selenium.webdriver.common.by import By
912
from selenium.webdriver.support import expected_conditions as EC
1013
from selenium.webdriver.support.ui import WebDriverWait
1114

1215
from common.core.deps import SessionDep
13-
from selenium.webdriver.chrome.options import Options
14-
from selenium.webdriver.chrome.service import Service
1516

1617
router = APIRouter(tags=["export"], prefix="/export")
1718

1819

1920
@router.get("/png")
2021
async def export(session: SessionDep):
21-
22+
user_data_dir = tempfile.mkdtemp()
2223

2324
options = Options()
25+
options.add_argument(f"--user-data-dir={user_data_dir}")
26+
options.add_argument("--no-sandbox")
27+
options.add_argument("--disable-dev-shm-usage")
2428
options.add_argument("--headless")
2529
service = Service(executable_path='/root/sqlbot/chromedriver-linux64/chromedriver')
2630
driver = webdriver.Chrome(service=service, options=options) # 或者使用webdriver.Firefox()等

0 commit comments

Comments
 (0)