#切换到命令行下
pip install selinum
phantomjs和firefox不需要驱动,[谷歌浏览器驱动下载地址](https://chromedriver.storage.googleapis.com/2.30/chromedriver_mac64.zip)
解压zip,放到PATH路径下,比如*unix的/usr/local/bin/下
#导入刚刚安装的selenium包
from selenium import webdriver
def fetch_web_page(url):
driver = webdriver.Chrome()
#打开浏览器,输入地址
driver.get(url)
try:
#浏览器点击点击按钮
driver.find_elements_by_id("User")[0].click()
#输入用户名
driver.find_element_by_id("user").send_keys("用户名")
#输入密码
driver.find_element_by_id("passw").send_keys("密码")
#点击点击按钮
driver.find_element_by_class_name("submit_btn").click()
time.sleep(5);
finally:
driver.close()
driver.quit()
#可执行
if __name__ == "__main__":
fetch_web_page("url地址")