Python + Selenium 基础篇 - 打开和关闭浏览器
1.首先要下载浏览器对应的driver,并放到你的python安装目录
Chrome浏览器(chromedriver): http://npm.taobao.org/mirrors/chromedriver/ (注意下载的版本是不是跟你的浏览器版本对应)
Firefox浏览器(geckdriver): https://github.com/mozilla/geckodriver/releases
2.打开Firefox
from selenium import webdriver
driver = webdriver.Firefox()
driver.maximize_window()
url = ("http://news.baidu.com")
driver.get(url)
3.打开Chrome
from selenium import webdriver
driver = webdriver.Chrome()
driver.maximize_window()
url = ("http://news.baidu.com")
driver.get(url)
4.打开IE
from selenium import webdriver
import time
driver = webdriver.Ie()
driver.maximize_window()
url = ("http://news.baidu.com")
driver.get(url)
5.关闭并退出浏览器
driver.quit()