大哥们,为什么爬虫会显示xpath爬取的列表为空
Traceback (most recent call last):
File "H:/python_text/Mock_login/网站验证码识别.py", line 9, in <module>
src = tree.xpath('//*[@id="imgCode"]/@src')[0]
IndexError: list index out of range
不好意思哈,大过年的还要打扰你们,辛苦啦!
大哥们,为什么爬虫会显示xpath爬取的列表为空
Traceback (most recent call last):
File "H:/python_text/Mock_login/网站验证码识别.py", line 9, in <module>
src = tree.xpath('//*[@id="imgCode"]/@src')[0]
IndexError: list index out of range
不好意思哈,大过年的还要打扰你们,辛苦啦!
错误提示:IndexError: list index out of range
说明,tree调用xpath没有匹配到对应的数据,你要看下这个xpath对应的节点数据是否存在,或者你写错了。
tree.xpath('//*[@id="imgCode"]/@src')