2

I'm trying to use spynner to auto-click some button in the HTML source code as a small test. But I'm receiving this error. Traceback (most recent call last): File "build\bdist.win32\egg\spynner\browser.py", line 287, in _on_reply AttributeError: 'Browser' object has no attribute 'manager'

Below is my code, which is following the guide here:https://github.com/makinacorpus/spynner/blob/master/examples/webkit_methods.py

import spynner
import libxml2

proxy_ip = "xxx.xxx.xxx.xxx";
browser = spynner.Browser()  

    # setting proxy ip  
browser.set_proxy(proxy_ip :'8080'); 
browser.show() 

try:  
        browser.load(url='http://xxx.html', load_timeout=10, tries=1)  
except spynner.SpynnerTimeout:  
        print 'Timeout.'  
else:  

        browser.wk_click('a[id="voteProjectBtn_10353150"]', wait_load=True)  
browser.close()  

I'm using Python 2.7, thanks for the help!

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Zhuoyi
  • 21
  • 2
  • can you share the full error? at no point in the above code do I see where you try to access Browser.manager, so it's hard to say with certainty what the error is. – Bee Smears Jan 31 '15 at 16:26
  • The whole error information is here: browser.load("xxx.html") File "build\bdist.win32\egg\spynner\browser.py", line 548, in load File "build\bdist.win32\egg\spynner\browser.py", line 440, in _wait_load spynner.browser.SpynnerTimeout: Timeout reached: 10 seconds – Zhuoyi Feb 01 '15 at 02:30
  • Having the same issue. I use Browser.load(xx) and only with some sites do I get the AttributeError. There is an issue for that on the Github page, which is still open – JasTonAChair Oct 18 '15 at 12:11

1 Answers1

-1

before browser.close(), you must distroy the loop javascript, some website has timming script, so you need distroy these script see the browser.py, change the method "_manager_create_request" , before browser.close(), set self.closeflag = True

def _manager_create_request(self, operation, request, data):
    if self.closeflag:
        return None
    url = unicode(request.url().toString())
    operation_name = self._operation_names[operation].upper()
    self._debug(INFO, "Request: %s %s" % (operation_name, url))
    for h in request.rawHeaderList():
        self._debug(DEBUG, "  %s: %s" % (h, request.rawHeader(h)))
    if self._url_filter:
        if self._url_filter(self._operation_names[operation], url) is False:
            self._debug(INFO, "URL filtered: %s" % url)
            request.setUrl(QUrl("about:blank"))
        else:
            self._debug(DEBUG, "URL not filtered: %s" % url)
    reply = QNetworkAccessManager.createRequest(self.manager,
        operation, request, data)
    return reply
Enamul Hassan
  • 5,266
  • 23
  • 39
  • 56
w.sky
  • 1
  • 1