Skip to content

Commit

Permalink
wip: add links()
Browse files Browse the repository at this point in the history
  • Loading branch information
noviluni committed May 4, 2021
1 parent 80509e4 commit f0a8c56
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions parsel/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,15 @@ def css(self, query):
"""
return self.xpath(self._css2xpath(query))

def links(self):
return [
link for link in self.xpath('//a/@href').getall()
if link and not (
link.startswith('#')
and not link.startswith(('javascript:', 'mailto:'))
)
]

def _css2xpath(self, query):
return self._csstranslator.css_to_xpath(query)

Expand Down

0 comments on commit f0a8c56

Please sign in to comment.