python+selenium開啟Google瀏覽器
阿新 • • 發佈:2019-02-11
前提準備:
1、安裝python3.6並配置環境變數
2、安裝selenium :pip install selenium
3、下載Google驅動:將chromedriver.exe 放在chrome瀏覽器安裝目錄下(同時設定使用者環境變數path:C:\Program Files (x86)\Google\Chrome\Application
__author__ = 'kevin' # -*- coding: UTF-8 -*- from selenium import webdriver import os from selenium import webdriver from selenium.webdriver.common.keys import Keys chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe" os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
url = 'http://pluscmstest.miaohealth.net/login.html'
driver.get(url)
diver.close()
driver.quit()