【问题标题】:Submit a javascript form with PyQuery in Python在 Python 中使用 PyQuery 提交 javascript 表单
【发布时间】:2012-03-27 16:08:56
【问题描述】:

我正在尝试结合使用 Python、PyQuery 和 Paste 从网页中提交 javacript。

我知道一点 Python,但我对 javascript 真的很陌生。

我尝试的是以下内容:

from pyquery import PyQuery as pq
import urllib
d = pq(url='http://www.optimustag.pt/'
f = d("#login-form")
f.attr["login-user"] = "somename"
f.attr["login-pass"] = "somepass"

但我到此为止,我找不到提交此表单的方法。

如果我这样做:print f,我会得到:

<form id="login-form" action="javascript:doLogin();">
                <input id="login-user" type="text" style="border: 0px solid #fff;width:120px; &#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;height:20px; font-family:Arial;font-size:14px;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;position:absolute;top:43px;left:17px;" value=""/><input id="login-pass" type="password" style="border: 0px solid #fff;width:120px; &#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;height:20px; font-family:Arial;font-size:14px;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;position:absolute; top:43px; left:154px;" value=""/><input id="login-remember" type="checkbox" style="position:absolute;top:73px;left:20px; &#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;border: 0px solid #fff;"/><a href="javascript:Registration.recover();" style="position:absolute;top: 75px; left: 151px; &#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;font-family:Arial;font-size:11px;font-decoration:underline;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;color:#000;width:80px; height:15px;"/>
                <input type="image" value="" id="login_enter_submit" src="css/blank.gif"/></form>

这是我的表格。

当然,如果在没有 PyQuery 的情况下在 Python 中有某种方法可以做到这一点,那也可以。

【问题讨论】:

    标签: javascript python forms pyquery


    【解决方案1】:

    没有办法做到这一点。 PyQuery 没有 js 模拟器。

    【讨论】:

    • 还有其他方法吗?例如,通过在 PyQuery 中使用 Paste,因为我知道我可以在 Python 中使用 AJAX 脚本。
    猜你喜欢
    • 2023-04-02
    • 2012-10-26
    • 2016-01-04
    • 2014-01-04
    • 2011-02-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多