AttributeError: 'module' object has no attribute 'open' Python 3.4 with robobrowser
AttributeError: 'module' object has no attribute 'open' Python 3.4 with robobrowser
所以,作为 mechanize 的替代品,因为 Visual Studio "needs" python 3.4,而 mechanize 与 3.4 不兼容,我发现 "robobrowser" 作为替代品,但我无法弄清楚为什么 browser.open returns "AttributeError: 'module' object has no attribute 'open'"
import re
from robobrowser import browser
import time
br = browser
br.open("Website")
br.select_form(name="game-pin-input")
print ("Enter the game pin")
response = br.submit()
time.sleep(3)
有什么建议或替代品吗?
编辑:文档可在此处找到,"open" 有效。
https://robobrowser.readthedocs.org/en/latest/api.html#module-robobrowser.browser
我猜 browser
是一个模块;根据 the docs,你想要 RoboBrowser
,你需要在 open
之前构建一个实例。大致匹配您的代码:
from robobrowser import RoboBrowser
# Browse to Genius
br = RoboBrowser(history=True) # No idea if history matters
br.open("Website")
我猜 robobrowser.browser
是一些可导入的实现内部模块,但根本不是您想要的。
更新:根据your own docs link,robobrowser.browser
只是一个模块,RoboBrowser
是你需要的class , 确认我之前的陈述(RoboBrowser
可能为了方便起见暴露在 robobrowser
本身)。
所以,作为 mechanize 的替代品,因为 Visual Studio "needs" python 3.4,而 mechanize 与 3.4 不兼容,我发现 "robobrowser" 作为替代品,但我无法弄清楚为什么 browser.open returns "AttributeError: 'module' object has no attribute 'open'"
import re
from robobrowser import browser
import time
br = browser
br.open("Website")
br.select_form(name="game-pin-input")
print ("Enter the game pin")
response = br.submit()
time.sleep(3)
有什么建议或替代品吗?
编辑:文档可在此处找到,"open" 有效。 https://robobrowser.readthedocs.org/en/latest/api.html#module-robobrowser.browser
我猜 browser
是一个模块;根据 the docs,你想要 RoboBrowser
,你需要在 open
之前构建一个实例。大致匹配您的代码:
from robobrowser import RoboBrowser
# Browse to Genius
br = RoboBrowser(history=True) # No idea if history matters
br.open("Website")
我猜 robobrowser.browser
是一些可导入的实现内部模块,但根本不是您想要的。
更新:根据your own docs link,robobrowser.browser
只是一个模块,RoboBrowser
是你需要的class , 确认我之前的陈述(RoboBrowser
可能为了方便起见暴露在 robobrowser
本身)。