gpt4 book ai didi

python - 使用 Python 填写 Ajax 表单

转载 作者:行者123 更新时间:2023-12-01 06:08:30 25 4
gpt4 key购买 nike

我正在尝试使用 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))

mechanize 是填充该 ajax 框表单的正确模块吗?

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

最佳答案

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

关于python - 使用 Python 填写 Ajax 表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6929709/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com