Last active
February 18, 2018 16:04
-
-
Save uluQulu/54a2cf26345a05355c5c21c433bf6616 to your computer and use it in GitHub Desktop.
Standalone link grabber
This file contains 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 get_links(browser, tag, logger, media, element): | |
# Get image links in scope from tags | |
link_elems = element.find_elements_by_tag_name('a') | |
sleep(2) | |
links = [] | |
try: | |
if link_elems: | |
new_links = [link_elem.get_attribute('href') for link_elem in link_elems | |
if link_elem and link_elem.text in media] | |
links.extend(new_links) | |
else: | |
logger.info("'{}' tag does not contain a picture".format(tag[1:] if tag[:1] == '#' else tag)) | |
except BaseException as e: | |
logger.error("link_elems error {}".format(str(e))) | |
return links |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Click on RAW and copy