1尚粘、啟動firefox
不需要下載驅(qū)動庙睡,但是selenium3.0以上版本需要下載“geckodriver”蹈矮,放置在環(huán)境變量可以訪問到的地方长已。
下載:https://github.com/mozilla/geckodriver/releases
#coding:utf-8
from selenium import webdriver
from time import sleep
driver=webdriver.Firefox()
driver.get("http://mail.126.com")
2畜眨、啟動chrome
驅(qū)動下載:http://chromedriver.storage.googleapis.com/index.html
# -*- coding:utf-8 -*-
from selenium import webdriver
import os
# chromedriver.exe 實際安裝路徑, 筆者這里放置在D盤python目錄
googledriver = "D:\\Python27\\chromedriver.exe"
os.environ["webdriver.chrome.driver"] = googledriver
driver = webdriver.Chrome(googledriver)
url='http://mail.126.com'
driver.get(url)
driver.close()
3、啟動IE
驅(qū)動下載:http://selenium-release.storage.googleapis.com/index.html
IE設(shè)置:Internet選項-安全
?
?
# -*- coding:utf-8 -*-
from selenium import webdriver
import os
#iedriver.exe 實際安裝路徑, 筆者這里放置在C盤根目錄
iedriver = "D:\\Python27\\IEDriverServer.exe"
os.environ["webdriver.ie.driver"] =iedriver
driver = webdriver.Ie(iedriver)
url='http://mail.126.com'
driver.get(url)
driver.close()