Skip to content

Instantly share code, notes, and snippets.

@scraperdragon
Created September 4, 2012 13:41
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 scraperdragon/3621256 to your computer and use it in GitHub Desktop.
Save scraperdragon/3621256 to your computer and use it in GitHub Desktop.
Get the value of a SELECT dropdown box in LXML
def get_select_value(node):
# node is an LXML element (SELECT tag)
try:
return node.cssselect("option[selected='selected']")[0].text
except IndexError:
return node.cssselect("option")[0].text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment