获取标题时报错

来源:2-9 爬取京东网的数据

慕粉3543411

2019-05-30

Traceback (most recent call last):
File “D:/pydemo/demo/pyTools/spider_jd2.py”, line 33, in
spider(sn)
File “D:/pydemo/demo/pyTools/spider_jd2.py”, line 26, in spider
title = li.xpath(‘div/div[@class=“p-name”]/a/text()’)
AttributeError: ‘lxml.etree._ElementUnicodeResult’ object has no attribute ‘xpath’

Process finished with exit code 1

写回答

1回答

NavCat

2019-06-03

pip install lxml
重新安装一下

0
1
慕粉3543411
非常感谢!
2019-06-03
共1条回复

手把手教你把Python应用到实际开发 不再空谈语法

学会项目开发思路,掌握Python高阶用法。

1341 学习 · 244 问题

查看课程