准备环境
Chrome68+chromedriver2.41+selenium2.53.6+或python3
Firefox44+selenium2.53.6+python3.6)
载地址http://chromedriver.storage.googleapis.com/index.html
1.通过id定位-find_element_by_id()
用firebug通过查看页面元素,找到搜索输入框id属性值,输入关键字搜索
driver.find_element_by_id(“kw”).send_keys(u“悠悠 博客")
用firebug通过查看页面元素,找到搜索按钮id属性值,然后click点击
driver.find_element_by_id(“su”).click()
send_keys() :输入框输入字符串
click() :鼠标点击事件注意:senekeys输入中文时,需在字符串前面加u(unicode编码)