def get_elements(html_file, tags):
with open(html_file) as f:<EOL><INDENT>document = BeautifulSoup(f, '<STR_LIT>')<EOL>def condition(tag, attr):<EOL><INDENT>return lambda x: x.name == tagand not x.get(attr, '<STR_LIT:http>').startswith(('<STR_LIT:http>', '<STR_LIT>'))<EOL><DEDENT>all_tags = [(attr, document.find_all(condition(tag, attr)))<EOL>for tag, attr in tags]<EOL>return all_tags<EOL><DEDENT>
Extract all the elements we're interested in.

Returns a list of tuples with the attribute as first item
and the list of elements as the second item.