- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用一年前编写的 Python 代码。
我的操作系统是 Ubuntu 10.10 和 Python 2.6.6。
代码片段是:
import mechanize
.....
br.select_form(nr=0)
br['sign_in[email]'] = username
br['sign_in[password]'] = password
tc = mechanize.TextControl('hidden', 'token', {'value':token})
tc.add_to_form(br.form)
self.submit()
当我运行这段代码时,我得到了这个错误:
AttributeError: 'module' object has no attribute 'TextControl'
怎么了?原作者的意图是什么?当我用谷歌搜索 TextControl
时,似乎没有任何内容与 mechanize 相关。我通过 apt-get install python-mechanize
安装 mechanize。
最佳答案
查看源代码,您安装的 mechanize 版本似乎不是您尝试运行的代码的正确版本。
此来源:
https://github.com/jjlee/mechanize/blob/master/mechanize/__init__.py
建议 TextControl
应该存在(尽管它已被弃用)。
我建议您删除 python-mechanize(使用 apt),而是使用 easy_install(或从源代码下载并安装)来使用更新的 mechanize 副本。
当然,如果您安装了依赖旧版本 mechanize 的其他软件包,您最好获取源代码并从中加载模块。
关于Python: mechanize has no attribute 'TextControl' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9340958/
我正在使用一年前编写的 Python 代码。 我的操作系统是 Ubuntu 10.10 和 Python 2.6.6。 代码片段是: import mechanize ..... br.select_
Resharper 声称要吃自己的狗粮,具体来说,他们声称 Resharper 的许多功能都是在 R# (OpenAPI) 之上编写的。我正在编写一个简单的插件来修复所选内容的当前文档的注释。当这个插
我正在尝试使用 mechanize 解析 html 表单。表单本身有任意数量的隐藏字段,并且字段名称和 ID 是随机生成的,因此我没有明显的方法来直接选择它们。显然,使用名称或 ID 已经过时了,并且
我正在尝试将邮政编码信息输入到 http://www.gasbuddy.com/然后使用 Mechanize 单击“搜索” 所以我能够使用以下数据抓取表单: 我能够将文本插入到 TextContr
我是一名优秀的程序员,十分优秀!