You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
773 B
773 B
Jon_Jen
from selenium import webdriver from selenium.webdriver.chrome.options import Options
由于该服务器是在linux上运行,没有可视化界面,所有我们要使用无头模式
对谷歌浏览器进行设置
chrome_options = Options()
linux上运行时需要以最高权限运行
chrome_options.add_argument('--no-sandbox')
设置无头模式,不打开浏览器窗口
chrome_options.add_argument('--headless')
设置浏览器窗口大小
chrome_options.add_argument('window-size=1920,1080') driver = webdriver.Chrome(executable_path=r'chromedriver', options=chrome_options) #获取chrome浏览器的驱动,并启动Chrome浏览器 driver.get('https://www.baidu.com') # 打开百度 print(driver.current_url) # 打印浏览器当前url