def extract_nodes(soup, nodename, attr = None, value = None):
tags = soup.find_all(nodename)<EOL>if attr != None and value != None:<EOL><INDENT>return list(filter(lambda tag: tag.get(attr) == value, tags))<EOL><DEDENT>return list(tags)<EOL>
Returns a list of tags (nodes) from the given soup matching the given nodename.
If an optional attribute and value are given, these are used to filter the results
further.