赞
踩
- #使用以下方法在运行的时候可以不打开浏览器,运行速度杠杠的
- from selenium import webdriver
- import time
-
- path = 'G:\chromedriver_win32/chromedriver.exe'
-
- # 不开网页搜索
- option = webdriver.ChromeOptions()
- option.add_argument("headless")
- driver = webdriver.Chrome(path, chrome_options=option)
- # 开网页搜索
- # driver = webdriver.Chrome(path)
-
- # 打开百度并搜素selenium
- driver.get("https://www.baidu.com")
- print(driver.title)
- driver.find_element_by_id("kw").send_keys("selenium")
- time.sleep(1)
- driver.find_element_by_id("su").click()
- time.sleep(1)
- print(driver.title)
- driver.quit()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。