Python 3.x 的机械化

发布于 2024-10-03 23:12:40 字数 196 浏览 4 评论 0原文

有什么方法可以将 Mechanize 与 Python 3.x 一起使用吗?

或者有什么可以在 Python 3.x 中工作的替代品吗?

我已经搜索了几个小时,但没有找到任何东西:(

我正在寻找如何使用 Python 登录该网站的方法,但该网站使用 javascript。

提前致谢,

Adam。

is there any way how to use Mechanize with Python 3.x?

Or is there any substitute which works in Python 3.x?

I've been searching for hours, but I didn't find anything :(

I'm looking for way how to login to the site with Python, but the site uses javascript.

Thanks in advance,

Adam.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

っ左 2024-10-10 23:12:40

lxml.html 提供表单处理工具并支持 Python 3。

lxml.html provides form handling facilities and supports Python 3.

゛清羽墨安 2024-10-10 23:12:40

我正在开发一个类似的项目,但 mechanize 的常见问题解答明确表示他们不打算很快支持 3x。有什么理由必须用 3 来编写代码吗?

我试图解决这个问题的方法是通过模拟带有表单提交的java脚本,这需要一些逆向工程。 (也就是说,如果 javascript 以提交表单结束,并且您可以找到脚本传递给 Submit() 的参数,只需按照 mechanize 文档中的示例操作

http://wwwsearch.sourceforge.net/mechanize/

br.select_form(name="order")
# Browser passes through unknown attributes (including methods)
# to the selected HTMLForm.
br["cheeses"] = ["mozzarella", "caerphilly"]  # (the method here is __setitem__)
# Submit current form.  Browser calls .close() on the current response on
# navigation, so this closes response1
response2 = br.submit()

I'm working on a similar project, but the faq for mechanize explicitly says they don't intend on supporting 3x any time soon. Is there a reason the code has to be written in 3?

The way I'm trying to tackle the problem is by emulating the java script with form submits, it takes some reverse engineering. (which is, if the javascript ends by submitting a form, and you can find the arguments the script passes to the submit(), just follow the example from the mechanize doc

http://wwwsearch.sourceforge.net/mechanize/

br.select_form(name="order")
# Browser passes through unknown attributes (including methods)
# to the selected HTMLForm.
br["cheeses"] = ["mozzarella", "caerphilly"]  # (the method here is __setitem__)
# Submit current form.  Browser calls .close() on the current response on
# navigation, so this closes response1
response2 = br.submit()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文