简体   繁体   English

如何在python中使用机械化单击?

[英]How to click with mechanize in python?

i have a form which is used for authentication. 我有用于身份验证的表格。 but in this form there are no submit button but it has used an <input> as a button . 但是在这种形式下,没有提交按钮,但是它使用了<input>作为按钮。 now i am confused how to click this type of button with MECHANIZE. 现在我很困惑如何用MECHANIZE单击这种类型的按钮。

页面详细信息

till now i had done this: 到目前为止,我已经做到了:

import urllib
import re
import mechanize
from base64 import b64encode

and can this be done in Java script? 可以用Java脚本完成吗?

br = mechanize.Browser()


response = br.open("http://xyz.com");
#print response.code
#print response.geturl()

br.select_form("login")
br.form['j_username'] = 'user'
br.form['j_password'] = 'pass'

That's not an error. 那不是错误。 Read the response - it's a filelike object. 阅读响应-这是一个类似文件的对象。

br.select_form("login")
br.form['j_username'] = 'xyz'
br.form['j_password'] = 'pass'
pag2 = br.submit()
html = pag2.read()
print html

This is a submit button. 一个提交按钮。 A submit button in HTML is by definition an <input> element of type submit . 在HTML提交按钮是通过定义一个<input>类型的元素submit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM