http://chromedriver.storage.googleapis.com/index.html
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from bs4 import BeautifulSoup as bs
#这个是一个用来控制chrome以无界面模式打开的浏览器
#创建一个参数对象,用来控制chrome以无界面的方式打开
options = Options()
#后面的两个是固定写法 必须这么写
options.add_argument('--headless')
options.add_argument('--disable-gpu')
#驱动路径 谷歌的驱动存放路径
path = r'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Scripts\chromedriver.exe'
#创建浏览器对象
browser = webdriver.Chrome(executable_path=path,options =options)
chrome_options
url ='http://www.baidu.com/'
browser.get(url)
time.sleep(3)
html = browser.page_source
html = bs(html,'lxml')
print(html.title)
browser.save_screenshot('baid.png')