mechanize icon indicating copy to clipboard operation
mechanize copied to clipboard

select_form by id

Open mediafactory opened this issue 13 years ago • 5 comments

would be nice, too

mediafactory avatar Mar 10 '12 08:03 mediafactory

You can select the form by its index.

form = mechanize.Browser().select_form(nr=0)

nr=0 is the first form, nr=1 would be the second form on the page, etc.

Deusdies avatar Apr 17 '12 21:04 Deusdies

i meant html id

mediafactory avatar Apr 18 '12 12:04 mediafactory

I know what you meant, and yes it would be a nice feature, but for now you can select it by index and name, which should work for all forms.

Deusdies avatar Apr 18 '12 12:04 Deusdies

I saw someone do this with perl mechanize and was sad to see python mechanize didn't have it.

It is actually pretty useful, I find a lot of forms that have an "id" attribute but not name. The index/nr I don't like using since adding other forms to page changes it, so selecting by name or "id" is much better since adding new forms to page wont break it.

Ive added it myself to the code... now to just find out how i can attach a patch file somewheres here... :|

Well the email list looks more active, so ill send it there...

ddan39 avatar Sep 28 '12 23:09 ddan39

Hi. Is this in the plans somehow? @ddan39 - can you please provide your solution? I need this badly and urgent...

ror6ax avatar Dec 19 '14 14:12 ror6ax