我想在這里抓取網址:我試過這些: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()
&如果您只想獲取第一個網址,請?zhí)砑?/p>
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
提交
取消