一、环境
1.chrome浏览器
查看浏览器版本:菜单-帮助-关于GoogleChrome(G)
2.chromeDriver
网址1:http://chromedriver.chromium.org/(需要翻墙)
网址2:http://npm.taobao.org/mirrors/chromedriver/(不需翻墙)
根据chrome版本,安装对应驱动
3.selenuim安装:
pip install selenium
4.测试程序:
from selenium import webdriver
browser = webdriver.Chrome()
browser.get('http://www.baidu.com/')
运行程序,将成功打开百度页面。
扫描二维码关注公众号,回复:
2998293 查看本文章
二、API
find_element_by_name
find_element_by_css_selector
find_element_by_tag_name
find_element_by_xpath
xpath获取:安装chrome-xpath插件
find_element_by_class_name