Created
November 29, 2018 15:05
-
-
Save victor-torres/98757b1cd65a5af12e0f55afe664f7cb to your computer and use it in GitHub Desktop.
[Scrapy] Remove elements from the document based on a selector or list of selectors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_selector(selector): | |
""" | |
Remove elements from the document based on a selector or list of selectors. | |
:param selector: Selector object or Selector iterable. | |
""" | |
if not hasattr(selector, '__iter__'): | |
selector = [selector] | |
for sel in selector: | |
sel.root.getparent().remove(sel.root) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi victor-torres ,
Thank you.... It worked !!! 👍 💯