【问题标题】:Using twill's builtin mechanize distribution throws AttributeError on _debug?使用斜纹布的内置机械化分布会在 _debug 上引发 AttributeError?
【发布时间】:2011-09-02 00:28:25
【问题描述】:

我使用 twill (0.9),并且我还想访问其内置的 mechanize 发行版(在 Python 2.6.6 上)。 我阅读了所有文档,但我不清楚他们是否支持或推荐,如果是,他们当然不会公开它。 看来你可以做到:

import _mechanize_dist as mechanize
br = mechanize.Browser()
br.open('http://www.yahoo.com')

然而 mechanize 在robotparser._debug 上抛出了下面的愚蠢的 AttributeError。我不应该尝试使用它吗?还是只是机械化处理草率的异常? (斜纹布本身可以正常工作:twill.commands.go('http://www.yahoo.com')

Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    br.open('http://www.yahoo.com')
  File "C:\Dev\Python26\lib\site-packages\twill-0.9-py2.6.egg\twill\other_packages\_mechanize_dist\_mechanize.py", line 212, in open
    return self._mech_open(url, data)
  File "C:\Dev\Python26\lib\site-packages\twill-0.9-py2.6.egg\twill\other_packages\_mechanize_dist\_mechanize.py", line 238, in _mech_open
    response = UserAgentBase.open(self, request, data)
  File "C:\Dev\Python26\lib\site-packages\twill-0.9-py2.6.egg\twill\other_packages\_mechanize_dist\_opener.py", line 175, in open
    req = meth(req)
  File "C:\Dev\Python26\lib\site-packages\twill-0.9-py2.6.egg\twill\other_packages\_mechanize_dist\_http.py", line 440, in http_request
    self.rfp.read()
  File "C:\Dev\Python26\lib\site-packages\twill-0.9-py2.6.egg\twill\other_packages\_mechanize_dist\_http.py", line 387, in read
    robotparser._debug("parse lines")
AttributeError: 'module' object has no attribute '_debug'

(最后一个问题是:我不知道同时使用 twill 和 mechanize 命令有什么注意事项?)

【问题讨论】:

    标签: python mechanize twill


    【解决方案1】:

    目前与 twill 一起提供的 mechanize 分布是古老的。 最近twill mailing list有升级活动。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-08
      • 2013-10-17
      • 1970-01-01
      相关资源
      最近更新 更多