Skip to content

Instantly share code, notes, and snippets.

@petrushev
Created September 25, 2016 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petrushev/ec80aff9c69e6684fcfddfeb171b10b6 to your computer and use it in GitHub Desktop.
Save petrushev/ec80aff9c69e6684fcfddfeb171b10b6 to your computer and use it in GitHub Desktop.
def extractattr(attr_name):
def _decorator(fc):
def wrapped(*args, **kwargs):
ellist = fc(*args, **kwargs)
return [el.attrib[attr_name] for el in ellist]
return wrapped
return _decorator
def extracttext(fc):
def wrapped(*args, **kwargs):
ellist = fc(*args, **kwargs)
return [el.text_content() for el in ellist]
return wrapped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment