This topic created in 2669 days ago, the information mentioned may be changed or developed.
time_list = response.xpath('//div[@class="listBox"]/ul[@class="list"]//li/span/text()').extract()
这个 xpath 我拆分成这样
for item in response.xpath('//div[@class="listBox"]/ul[@class="list"]//li'):
time=item.xpath('/span/text').extract()[0]
title=item.xpath('/a/text()').extract()[0]
link=item.xpath('/a/@href').extract()[0]
print(time)
print(title)
print(link)
我这样写的话会报错,如何写才是正确的?
1 replies • 2019-01-11 09:31:28 +08:00
 |
|
1
sikong31 Jan 11, 2019
time=item.xpath('/span/text').extract()[0] title=item.xpath('/a/text()').extract()[0] link=item.xpath('/a/@href').extract()[0]
前面的 / 删掉就行了
|