Issue
I am trying to extract href
starting with magnet
:
item['magnet']=response.xpath('//[@id="content"]/article/div[starts-with(@href,"magnet:")]/@href').extract()
I get empty results.
Thanks in advance for any help.
Solution
Instead of trying to extract specific link with magnet
I propose to
1.Extract all <a>
tags.
2.Filter all links that don't contain magnet:
in href
attribute:
def parse(self, response):
....
item["magnet"] = [link for link in response.css("a::attr(href)").extract() if "magnet:" in link]
Answered By - Georgiy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.