I am using scrapy with xpath to extract data from a webpage. My html response looks like this,
I want to extract the href link present in the highlighted "a" tag .
Usually I use response.xpath('//a[@id="jr-alt-sw"]/@href') to get the data, but here I think due to the namespace problem the result is empty. How can I get the data if namespace is present.
Any help is appreciated!!
Is that true about namespace? Another reason to use css instead:
response.css('a#jr-alt-sw::attr(href)')
此处选择的a
标签没有可用的href
属性,请查看下a
包含href
属性的a
标签。
response.xpath('//a[@id="jr-pdf-sw"]/@href')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.