我想在这里抓取网址:我试过这些:response.xpath('//header[@class="geodir-entry-header"]/a/@href').extract()response.xpath('//div[class="geodir-content "]/header/a/@href').extract()response.xpath('//div[@class="geodir-content "]/header[@class="geodir-entry-header"]/a/@href').extract()都返回了一个空列表。
2 回答
慕桂英4014372
TA贡献1871条经验 获得超13个赞
做
response.xpath('//h3[@class="geodir-entry-title"]/a/@href').extract() 或者 response.xpath('//header[@class="geodir-entry-header"]/h3/a/@href').extract()
为你工作?
看起来您刚刚错过了h3包含a您需要的标签的标签。
紫衣仙女
TA贡献1839条经验 获得超15个赞
您所需要的只是添加您不小心错过的 h3 标签。
response.xpath('//header[@class="geodir-entry-header"]/h3/a/@href').extract()&如果您只想获取第一个网址,请添加
response.xpath('//header[@class="geodir-entry-header"]/h3/a/@href').extract_first()或者
response.xpath('//header[@class="geodir-entry-header"]/h3/a/@href').extract()[0]添加回答
举报
0/150
提交
取消
