Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

AttributeError: 'module' object has no attribute 'RobustFactory'` #8

Open
Villodre opened this issue Jun 7, 2017 · 7 comments
Open

Comments

@Villodre
Copy link

Villodre commented Jun 7, 2017

I get this output when running the script on Windows 10 x64 build 1703, python 2.7:

Using BeautifulSoup version 4.6.0 Using mechanize version 0.3.3 No handlers could be found for logger "root" Using fake_useragent version 0.1.7 Traceback (most recent call last): File "amazon-vine.py", line 454, in <module> br = login() File "amazon-vine.py", line 134, in login br = mechanize.Browser(factory = mechanize.RobustFactory()) AttributeError: 'module' object has no attribute 'RobustFactory'

May it be related to this issue?
python-mechanize/mechanize#5

@timur-tabi
Copy link
Owner

Makes sense. Can you edit the code and try it?

@Villodre
Copy link
Author

Villodre commented Jun 7, 2017

I'm sorry I don't have any programming skills - so I uninstalled mechanize 0.3.3 and installed 0.2.5 in order to get around this issue.

I did minimal editing to the script in order to solve a BS4 warning and also to change domain name from amazon.com to amazon.es (my regional Amazon site) plus translating the "Exclsusive Vine Club" message and works beautifully apart from that, so thanks a lot for your work.

May I ask you how do you actually "use" this script? Do you keep a terminal window opened and take a look at it from time to time?

@timur-tabi
Copy link
Owner

I run the script in a window that is minimized. When a new item appears, the script opens a web browser window. It's a bit annoying if I'm typing when the window appears, but it hasn't caused any real problems.

I have plans to add an option for running an arbitrary script.

@Villodre
Copy link
Author

Villodre commented Jun 8, 2017

That's actually the best behaviour I can think of. I don't want to impose on you, but I can't get the script to work with Firefox on a Mac (macOS 10.12.5, FireFox 53.0.3)

Using BeautifulSoup version 4.6.0
Using mechanize version 0.2.5
No handlers could be found for logger "root"
Using fake_useragent version 0.1.7
('Firefox session filename does not exist:', '/Volumes/Macintosh HD/home/angelvillodre/Library/Application Support/Firefox/Profiles/z3u3nd3i.default/sessionstore.js')
Logging into Amazon.com
Opening Your Queue website
Reading response
Parsing response
Found 9 items
Opening Vine For All website
Reading response
Parsing response
Found 9 items
Waiting 10 minutes
Waiting 10 minutes
Waiting 10 minutes
Waiting 10 minutes
Waiting 10 minutes
Waiting 10 minutes
Waiting 10 minutes

BeautifulSoup4 complained of not being able to load a default renderer, even when I installed 'pip install html5lib' so it's using lxml instead. When trying to run under --browser=chrome parameter it simply states that there are no Amazon session data on Chrome.

Using BeautifulSoup version 4.6.0
Using mechanize version 0.2.5
No handlers could be found for logger "root"
Using fake_useragent version 0.1.7
No Amazon session data found in browser "chrome"

@timur-tabi
Copy link
Owner

So the "session filename does not exist" is apparently something new in Firefox. You have to quit Firefox before starting amazon-vine.py, because apparently Firefox now creates the session file only after it quits. I will try to make a permanent fix later. However, the fact that the script works even without the session data makes it wonder whether Amazon fixed their web site so that I no longer need the session data in order to log in.

As for bs4, try editing this line:

br = mechanize.Browser(factory = mechanize.RobustFactory())

and change it to

br = mechanize.Browser()

@Villodre
Copy link
Author

Villodre commented Jun 8, 2017

Please note that in FireFox (on Mac) it only checks once for the item queue.

I've modified the line and now on Windows I can use the latest version of mechanize without any warning. However, when trying on a Mac with FireFox it throws this output:

Using BeautifulSoup version 4.6.0
Using mechanize version 0.3.0
No handlers could be found for logger "root"
Using fake_useragent version 0.1.7
Logging into Amazon.com
General Error cannot import name viewkeys

It's still unable to read session data from Chrome on a Mac, though.

@timur-tabi
Copy link
Owner

timur-tabi commented Jun 8, 2017

It looks like browsercookie has some bugs in it. I can try to debug them, but not any time soon.

I filed a bug with browsercookie: https://bitbucket.org/richardpenman/browsercookie/issues/14/sessionstorejs-does-not-exist-if-firefox

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants