selenium 先用有頭模式~~再啟用無頭模式~~要如何寫?
selenium 先用有頭模式~~手動登入帳號~~~~
再啟用無頭模式~~要如何寫?
程序代码:
import requests import re from datetime import datetime, date from webdriver_manager.chrome import ChromeDriverManager import time from selenium import webdriver from selenium.webdriver.support.ui import Select from selenium.webdriver.support import expected_conditions as EC #啟用有頭模式 chrome_options = webdriver.ChromeOptions() #chrome_options.add_argument('--headless') # 啟動無頭模式 #chrome_options.add_argument('--disable-gpu') # windowsd必須加入此3 driver = webdriver.Chrome(ChromeDriverManager().install(),chrome_options=chrome_options) driver.get('https://bbs.bccn.net/forum-246-1.html') driver.set_window_size(1000, 1000) driver.implicitly_wait(20) #手動登入帳號 time.sleep(20) #啟用無頭模式 chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') # 啟動無頭模式 chrome_options.add_argument('--disable-gpu') # windowsd必須加入此3 driver = webdriver.Chrome(ChromeDriverManager().install(),chrome_options=chrome_options) driver.get('https://bbs.bccn.net/forum-246-1.html')