Linux安装chrome
yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
或者
yum install google-chrome-stable.x86_64
安装必要的库:
yum install mesa-libOSMesa-devel gnu-free-sans-fonts wqy-zenhei-fonts
谷歌无头浏览器下载
https://chromedriver.chromium.org/
解压
unzip chromedriver_linux64.zip
给执行权限
chmod +x /usr/bin/chromedriver
获取元素方法
#使用下面的方法,查找指定的元素进行操作即可
find_element_by_id 根据id找节点
find_elements_by_name 根据name找
find_elements_by_xpath 根据xpath查找
find_elements_by_tag_name 根据标签名找
find_elements_by_class_name 根据class名字查找
bd_input = browser.find_element_by_id('kw').send_keys('小猪配齐')
#在此截屏
browser.save_screenshot(r'phantomjs\xiaozhu.png')
time.sleep(3)
bd_sous = browser.find_element_by_id('su').click()
#在此截屏
browser.save_screenshot(r'phantomjs\sous.png')
time.sleep(3)