Skip to content

Instantly share code, notes, and snippets.

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 dyerrington/6850e459c37b3f01e4049505c1634256 to your computer and use it in GitHub Desktop.
Save dyerrington/6850e459c37b3f01e4049505c1634256 to your computer and use it in GitHub Desktop.
Debugged fetch_states for Cesar
def fetch_states():
"""
Return all <option> values for the <select> element with all states.
"""
data = {}
states = tree.xpath('//select[@name="state"]')
try:
for state in states[0].xpath('option'):
data[state.attrib['value']] = state.text_content()
except:
raise IndexError("Offset not found in states:", states)
return data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment