Skip to content

Instantly share code, notes, and snippets.

@urain39
Created January 31, 2019 05:34
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 urain39/b3fb5261f9fc8a4e33eb1a62b7f8b82d to your computer and use it in GitHub Desktop.
Save urain39/b3fb5261f9fc8a4e33eb1a62b7f8b82d to your computer and use it in GitHub Desktop.
def generate_urls(elems, attr="href"):
"""
@param elems: list
@param attr: str
@description generator to generate urls of elements
"""
for elem in elems:
if getattr(elem, "attrib", None):
url = elem.attrib.get(attr)
if url:
yield url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment