Python通过xpath查找元素通过selenium读取元素信息

#coding:utf-8
from selenium import webdriver
import time
url ='http://www.baidu.com'
driver = webdriver.Chrome()
driver.get(url)
time.sleep(1)
e=driver.find_element_by_xpath('//*[@id="lg"]/img')
print e
print e.text
print e.id
print e.tag_name
print type(e)
time.sleep(1)
driver.quit()
e.text 读取元素内容
e.tag_name 读取元素标签名

 

posted @ 2017-12-18 15:48  LLSix  阅读(2982)  评论(0编辑  收藏  举报