【问题标题】:Fill out Ajax forms in Python在 Python 中填写 Ajax 表单
【发布时间】:2011-08-03 16:16:33
【问题描述】:

我正在尝试使用 mechanize 模块填充 ajax 框的表单(只是我对这几种表单的术语),但它似乎不起作用。我不是网络程序员,但我知道 ajax 框会使用由浏览器处理的事件来更新自己的“onchange”。

Mechanize 似乎无法处理这个问题,在链接列表中(来自迭代器 Browser.links)我可以找到一个 url 'javascript:AjaxRetry();'带有错误消息作为文本,告诉我出了点问题。

这是我的代码:

import mechanize as m

br = m.Browser()
br.open(url)

br.select_form(nr=0)

# fill in one form (in a real browser, the other form refresh and are not disabled anymore)
br.set_value(code, br.form.controls[10].name)

# how to make it refresh now?
#br.submit() doesn't work (also br.click() does not work (no clickable around at all))

机械化是填充该 ajax 框表单的正确模块吗?

我无法将链接粘贴到该 ajax 框所在的页面,因为您必须先登录才能看到该框。

【问题讨论】:

  • 请出示代码。
  • 在我的脑海中,Mechanize 只公开了一个类似浏览器的 API。您必须自己解释 JavaScript。
  • 正如我所说,我不是网络程序员。那么我如何自己解释 JavaScrpt 呢?我知道如何查看 java 脚本代码,但我不知道如何在 mechanize 中自己执行?

标签: python ajax mechanize mechanize-python


【解决方案1】:

Mechanize 不处理 javascript,请参阅此答案了解更多详细信息和替代解决方案 How to properly use mechanize to scrape AJAX sites

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-10
    • 1970-01-01
    • 2021-06-20
    • 1970-01-01
    • 2020-12-02
    • 2011-05-16
    • 1970-01-01
    相关资源
    最近更新 更多