开发者

python and mechanize - seeing the options in a select field

开发者 https://www.devze.com 2023-02-06 18:57 出处:网络
My html form looks like this: <form name=\"someform\"> <select name=\"someid\"> <option value =\"option1\">

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

0

精彩评论

暂无评论...
验证码 换一张
取 消