jjlee / mechanize

Stateful programmatic web browsing in Python, after Andy Lester's Perl module WWW::Mechanize .
http://wwwsearch.sourceforge.net/mechanize/
618 stars 121 forks source link

select_form by id #60

Open mediafactory opened 12 years ago

mediafactory commented 12 years ago

would be nice, too

Deusdies commented 12 years ago

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.

mediafactory commented 12 years ago

i meant html id

Deusdies commented 12 years ago

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.

ddan39 commented 12 years ago

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...

ror6ax commented 9 years ago

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