every blog every motto: We would rather reuse an active dwarf than a sleeping giant.
0. 前言
用xpath 提取信息时,遇到的报错
1. 正文
源码
request_list = []
req = htmled.xpath('//div[@class="li_b_l"]')
for i in req:
request_list.append(i.get_attribute('innnerHTML'))
print(request_list)
报错
AttributeError: 'lxml.etree._Element' object has no attribute 'get_attribute'
解决办法:
问题出在,get_attribute是在selenium中xpath使用的方法,而不是单独的xpath,点我查看参考文章。在xpath中想获取源码或是属性有自己的方法