继$ P $的pssing在Python机械化一个提交按钮的结果 [英] Following the result of pressing a submit button in Python Mechanize

查看:200
本文介绍了继$ P $的pssing在Python机械化一个提交按钮的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有,我想通过机械化模块访问认证的站点。我能够登录,然后去我想要的页面。然而,因为页面认识到机械化不支持JavaScript,它要我点击提交按钮被重定向到一个非JavaScript的网站的一部分。我怎样才能简单地按一下按钮,然后阅读下面的网页的内容?

So I have an authenticated site that I want to access via the mechanize module. I'm able to log in, and then go to the page I want. However, because the page recognizes that mechanize doesn't have javascript enabled, it wants me to click a submit button to get redirected to a non javascript part of the site. How can I simply click the button and then read the contents of the page that follows that?

或者,有没有办法把它欺骗,以为我的JavaScript实现?

Or, is there a way to trick it into thinking that my javascript is enables?

谢谢!

推荐答案

如果提交按钮是真正的表单的提交输入元素,重定向照常工作表单提交的动作,并规定它在唯一的形式页面,您的浏览器机械化实例 BR ,下面应该工作

if that submit button is really a submit input element of the form, and the redirection works as usual form submit action, and provided that it's the only form in the page, your mechanize browser instance is br, following should work

br.select_form(nr=0) # select the first form
br.submit()

据我所知,有没有简单或中度可能的方式,如何在机械化效仿的javascript,可能的解决方法取决于什么是JavaScript究竟做

afaik, there's no simple or moderately possible way, how to emulate javascript in mechanize, possible workarounds depend on what is javascript exactly doing

这篇关于继$ P $的pssing在Python机械化一个提交按钮的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆