Reputation: 13
So, as a replacement for mechanize because Visual Studio "needs" python 3.4, and mechanize isn't compatible with 3.4, I found "robobrowser" as a replacement, but I'm having trouble trying to figure out why 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)
Any suggestions, or replacements?
Edit: The Documentation can be found here, and "open" is valid. https://robobrowser.readthedocs.org/en/latest/api.html#module-robobrowser.browser
Upvotes: 1
Views: 3930
Reputation: 155684
I'm guessing browser
is a module; according to the docs, you wanted RoboBrowser
, and you need to construct an instance before open
-ing anything. To roughly match your code:
from robobrowser import RoboBrowser
# Browse to Genius
br = RoboBrowser(history=True) # No idea if history matters
br.open("Website")
I'm guessing robobrowser.browser
is some implementation internal module that is importable, but not at all what you wanted.
Update: According to your own docs link, robobrowser.browser
is just a module, and RoboBrowser
is the class you needed, confirming my earlier statement (RoboBrowser
is probably exposed on robobrowser
itself for convenience).
Upvotes: 1