AttributeError: 'Browser' object has no attribute 'manager'
Opened this issue · 6 comments
HI
I want to scrapy some picture by following code
import spynner
import HTMLParser
import os
import urllib
class MyParser(HTMLParser.HTMLParser):
def handle_starttag(self, tag, attrs):
if tag == 'img':
url = dict(attrs)['src']
name = os.path.basename(dict(attrs)['src'])
if name.endswith('.jpg') or name.endswith('.png') or name.endswith('gif'):
print "Download.....", name
urllib.urlretrieve(url, name)
if name == "main":
browser = spynner.Browser()
browser.show()
browser.load("http://www.artist.cn/snakewu1994/StyleBasis_Four/en_album_607236.shtml")
Parser = MyParser()
Parser.feed(browser.html)
print "Done"
browser.close()
it can run,but it just only caught three pictures...... than it show me
Traceback (most recent call last):
File "build/bdist.linux-x86_64/egg/spynner/browser.py", line 287, in _on_reply
AttributeError: 'Browser' object has no attribute 'manager'
Can someone help me solve it? I don't know what happend for this. THK
This is happening to me also, says it's something to do with cookies. I'm scraping dynamic sites and wasn't trying to download cookies.
My use case is this:
....browser = spynner.Browser()
....browser.load(row[0],30)
....markup = browser._get_html()
....browser.close()
My terminal displays this
File "/usr/local/lib/python2.7/dist-packages/spynner/browser.py", line 287, in _on_reply
self.manager.cookieJar().allCookies())
AttributeError: 'Browser' object has no attribute 'manager'
I have the same problem.... Were you able to solve it?
I never did figure that one out. I ended up using PhantomJS instead
i find same problem , but i find this line:
browser.load(url,load_timeout=60)
change this load_timeout larger then it will ok
i think the page is too long before load
you can try it
my testing is the same, phantomjs has crash.use spynner has this error,too.
It is a bug in _on_reply method connected on finished signal of NManager
see Browser.init
mngr.finished.connect(self._on_reply)
when call browser.close() this signal fired after del self.manager
use this HACK for prevent a bug
browser = spynner.Browser(debug_level=spynner.DEBUG, debug_stream=debug_stream)
browser.load(...)
# wait load page
browser.wait_load(timeout=30)
# disconnect _on_reply handler
browser.manager.finished.disconnect()
# and close
browser.close()
NEED PATH close method of Browser, please add disonnect all handlers before clear resources
def close(self):
"""Close Browser instance and release resources."""
self.manager.finished.disconnect()
# disconnect other signals ..
if self.manager:
del self.manager
if self.webpage:
del self.webpage
if self.webview:
self.destroy_webview()
self.application.exit()