Skip to content

Instantly share code, notes, and snippets.

@jgomo3
Last active December 17, 2015 09:29
Show Gist options
  • Save jgomo3/5587712 to your computer and use it in GitHub Desktop.
Save jgomo3/5587712 to your computer and use it in GitHub Desktop.
# Código que solo satisface el req 2
class CNEEnlacesParser(HTMLParser):
def __init__(self):
self.enlaces = []
def handle_starttag(self, tag, attrs):
dict_attrs = dict(attrs)
si el tag es un "a" y tiene como atributos "id"=="region_ref" y "href":
enlaces.append(dict_attrs["href"])
def obtener_enlaces_cne_elec_pres_2013(html):
cne_enlace_parser = CNEEnlacesParser()
cne_enlace_parser.feed(html)
return cne_enlace_parser.enlaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment