青龙里的linux系统是轻量级的Alpine Linux 镜像,因此安装命令不是yum也不是apt,而是apk
进入青龙 docker 容器
docker exec -it qinglong bash
安装chromium
apk add chromium
安装chromedriver
apk add chromium-chromedriver
使用:
from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument('--headless') options.add_argument('--no-sandbox') options.add_argument('--disable-dev-shm-usage') options.add_argument("--disable-blink-features=AutomationControlled") options.add_experimental_option("excludeSwitches", ["enable-automation"]) options.add_argument('--ignore-certificate-errors') options.add_experimental_option("excludeSwitches", ["enable-logging"]) options.add_experimental_option('useAutomationExtension', False) browser = webdriver.Chrome(options=options) browser.get(" print(browser.title) browser.quit()
评论区