Created
September 4, 2012 13:41
-
-
Save scraperdragon/3621256 to your computer and use it in GitHub Desktop.
Get the value of a SELECT dropdown box in LXML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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