IE
#coding: utf-8 __author__ = 'KK' ''' 进入http://www.seleniumhq.org/download/,下载The Internet Explorer Driver Server 解压得到IEDriverServer.exe 放置到系统环境变量Path对应python对应目录下,如:D:\Develop\Python27\ 再运行该代码即可 ''' from selenium import webdriver import time driver = webdriver.Ie() driver.get("http://www.baidu.com") driver.find_element_by_id("kw").send_keys("guo") time.sleep(10) driver.find_element_by_id('su').click() time.sleep(5) driver.quit()
Chrome
#coding: utf-8 __author__ = 'KK' ''' 进入http://www.seleniumhq.org/download/,下载Google Chrome Driver 解压得到chromedriver.exe 放置到系统环境变量Path对应python对应目录下,如:D:\Develop\Python27\ 再运行该代码即可 ''' from selenium import webdriver import time driver = webdriver.Chrome() driver.get("http://www.baidu.com") driver.find_element_by_id("kw").send_keys("guo") time.sleep(10) driver.find_element_by_id('su').click() time.sleep(5) driver.quit()
FireFox
#coding: utf-8 __author__ = 'KK' ''' 进入http://www.seleniumhq.org/download/,下载Mozilla GeckoDriver 解压得到geckodriver.exe 放置到系统环境变量Path对应python对应目录下,如:D:\Develop\Python27\ 再运行该代码即可 ''' from selenium import webdriver import time driver = webdriver.Firefox() driver.get("http://www.baidu.com") driver.find_element_by_id("kw").send_keys("guo") time.sleep(10) driver.find_element_by_id('su').click() time.sleep(5) driver.quit()