JavaCrash
JavaCrash

Reputation: 13

AttributeError: 'module' object has no attribute 'open' Python 3.4 with robobrowser

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

Answers (1)

ShadowRanger
ShadowRanger

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

Related Questions