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.
Jon_Jen/README.md

18 lines
829 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Jon_Jen
# 导入selenium模快
from selenium import webdriver
# 导入selenium的设置模快
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