diff --git a/README.md b/README.md index 7ce4631..bbd38b7 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ # 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 \ No newline at end of file