python and mechanize - seeing the options in a select field
My html form looks like this:
<form name="someform">
<select name="someid">
<option value ="option1">
I'm tr开发者_如何学Goying to see all of the choices and be able to choose them.
I can select the form like this:
br.select_form("someform")
I can print(br) and see the SelectControl that I want. If I do:
print br["someid"]
that's just a list but only contains the first value. Is there an API for HTMLForm that I can look at?
Using br.possible_items("someid") gives you the list of options.
I think what you want to do is to print br.form
. This prints out ONLY the options in the form. Also, if anything in the form is a dropdown, then the options for that dropdown should also show up.
You could then use BeautifulSoup
to parse the options.
Hope this helps
精彩评论