使用机械化(Python)填写表单 [英] Using Mechanize (Python) to fill form
问题描述
我想使用python mechanize填充此页面上的表单,然后记录响应。我应该怎么做?当我使用以下代码在此页面上搜索表单时,它仅显示用于搜索的表单。我应该如何找到其他表单的表单名称,如姓名,性别等?
http://aapmaharashtra.org/join-us 代码: 您需要的表单(带有 通过使用浏览器开发工具,您可能会发现表单是从 以下是您应该从头开始的内容: 希望有帮助。 I want to fill the form on this page using python mechanize and then record the response. How should I do it? When I search for forms on this page using the following code, it shows the form only for the search. How should I locate the form name of the other form with fields such as name, gender etc? http://aapmaharashtra.org/join-us Code:
The form you need (with an By using browser developer tools you may find out that the form is loaded from Here's what you should start with then: Hope that helps. 这篇关于使用机械化(Python)填写表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
进口机械化
br = mechanize.Browser()
br.open(http://aapmaharashtra.org/join-us)
for br.forms()中的表单:
print表单名称:,form.name
print form
id =form1
)是动态加载的 - 这就是为什么您在 select_forms()
results。
http ://internal.aamaadmiparty.org/Directory/Format.aspx?master = blank
链接。
import mechanize
br = mechanize.Browser()
br.open(http://internal.aamaadmiparty.org/Directory/Format.aspx?master=blank)
br.select_form(nr = 0)
br.form ['ctl00 $ MainContent $ txtname'] ='测试名称'
#填写其他字段
req = br.submit()
import mechanize
br=mechanize.Browser()
br.open("http://aapmaharashtra.org/join-us")
for form in br.forms():
print "Form name:", form.name
print form
id="form1"
) is loaded dynamically on the fly - this is why you don't see it in the select_forms()
results.http://internal.aamaadmiparty.org/Directory/Format.aspx?master=blank
link. import mechanize
br = mechanize.Browser()
br.open("http://internal.aamaadmiparty.org/Directory/Format.aspx?master=blank")
br.select_form(nr=0)
br.form['ctl00$MainContent$txtname'] = 'Test Name'
# fill out other fields
req = br.submit()