Skip to content

Instantly share code, notes, and snippets.

@victor-torres
Created November 29, 2018 15:05
Show Gist options
  • Save victor-torres/98757b1cd65a5af12e0f55afe664f7cb to your computer and use it in GitHub Desktop.
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.
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)
@farheenfathima96
Copy link

Hi victor-torres ,

Thank you.... It worked !!! 👍 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment