[英]Python - mechanize - How to know if it works?
I am trying to signup in one form. 我正在尝试以一种形式进行注册。 But how I know if it works, or what errors the form is giving (like password to short)
但是我怎么知道它是否有效,或者表单给出了什么错误(例如密码短)
import mechanize
br = mechanize.Browser()
br.open("http://www.gutefrage.net/nutzer_hinzufuegen")
br.select_form(name = "regForm")
br.form['fRegister[nickname]'] = 'Username'
br.form['fRegister[email]'] = 'email@email.com'
br.form['fRegister[password]'] = 'password'
for i in range(0, len(br.find_control(name="fRegister[accept]").items)):
br.find_control(name="fRegister[accept]").items[i].selected =True
req = br.submit()
req = br.submit()
returns the html page to req
once submitted. req = br.submit()
将html页面提交给req
。 See the output using print req
or print req.read()
. 使用
print req
或print req.read()
查看输出。 If successfully logged in, the req will contain the logged in page 如果成功登录,则请求将包含已登录页面
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.