开发者

Using Python and Mechanize with ASP Forms

开发者 https://www.devze.com 2022-12-28 02:36 出处:网络
I\'m trying to submit a form on an .asp page but Mechanize does not recognize the name of the control.The form code is:

I'm trying to submit a form on an .asp page but Mechanize does not recognize the name of the control. The form code is:

<form id="form1" name="frmSearchQuick" method="post">
....
<input type="button" name="btSearchTop" value="SEARCH" class="buttonctl" onClick="uf_Browse('dledir_search_quick.asp');" >

My code is as follows:

br = mechanize.Browser()
br.open(BASE_URL)
br.select_form(name='frmSearchQuick')
resp = br.click(name='btSearchTop')

I've also tried the last line as:

resp = br.submit(name='btSearchTop')

The error I get is:

raise ControlNotFoundError开发者_运维问答("no control matching "+description) ControlNotFoundError: no control matching name 'btSearchTop', kind 'clickable'

If I print br I get this: IgnoreControl(btSearchTop=)

But I don't see that anywhere in the HTML.

Any advice on how to submit this form?


The button doesn't submit the form - it calls some javascript function.

Mechanize can't run javascript, so you can't use it to click that button.

The easy way out is to read that function yourself, and see what it does - if it just submits the form, then maybe you can get around it by submitting the form without clicking on anything.


you need to inspect element first, did mechanize recognize the form ?

for form in br.forms():
       print form
0

精彩评论

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