参考网站:
Selenium系列
以下内容到百度界面之后输入搜索内容hello!
之后返回百度页面底部备案信息
from selenium import webdriver
def main():
driver = webdriver.Chrome()
driver.get("http://www.baidu.com")
# 获得输入框的尺寸
size = driver.find_element_by_id('kw').size
print(size)
# 输入搜索内容并搜索
search_elem = driver.find_element_by_id('kw')
search_elem.send_keys('hello!')
search_elem.click()
# 返回百度页面底部备案信息
text = driver.find_element_by_id("cp").text
print(text)
# driver.quit()
input()
if __name__ == '__main__':
main()