简体   繁体   English

AttributeError:测试spynner时,“浏览器”对象没有属性“管理器”

[英]AttributeError: 'Browser' object has no attribute 'manager' when test spynner

I'm trying to use spynner to auto-click some button in the HTML source code as a small test. 我正在尝试使用spynner自动单击HTML源代码中的某些按钮,作为一个小测试。 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' 追溯(最近一次呼叫最近):_on_reply中的文件“ build \\ bdist.win32 \\ egg \\ spynner \\ browser.py”,第287行AttributeError:“浏览器”对象没有属性“管理器”

Below is my code, which is following the guide here: https://github.com/makinacorpus/spynner/blob/master/examples/webkit_methods.py 以下是我的代码,该代码遵循此处的指南: 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! 我正在使用Python 2.7,谢谢您的帮助!

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 browser.close()之前,您必须销毁循环javascript,某些网站具有定时脚本,因此您需要销毁这些脚本,请参见browser.py,更改方法“ _manager_create_request”,在browser.close()之前,设置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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “AttributeError: 'NoneType' 对象没有属性 'test'” 使用上下文管理器 - “AttributeError: 'NoneType' object has no attribute 'test'” using context manager AttributeError: 'Manager' 对象没有属性 - AttributeError: 'Manager' object has no attribute AttributeError:“测试”object 没有属性“a” - AttributeError: 'Test' object has no attribute 'a' Kivy - AttributeError: 'DialogContent' object 没有属性 'manager' - Kivy - AttributeError: 'DialogContent' object has no attribute 'manager' AttributeError:类型对象“测试”没有属性“选项卡” - AttributeError: type object 'Test' has no attribute 'tab' pytest:AttributeError:测试 class object 没有属性? - pytest: AttributeError: Test class object has no attribute? AttributeError:使用Django Rest框架运行生菜时,“ NoneType”对象没有属性“ _default_manager” - AttributeError: 'NoneType' object has no attribute '_default_manager' when running lettuce with django rest framework 使用命名空间和共享 memory dict 时关闭管理器错误“AttributeError: 'ForkAwareLocal' object 没有属性 'connection'” - Shutting down manager error "AttributeError: 'ForkAwareLocal' object has no attribute 'connection'" when using namespace and shared memory dict 出现错误:AttributeError: 'Flask' 对象没有属性 'login_manager' - Getting an error: AttributeError: 'Flask' object has no attribute 'login_manager' Django错误:“管理器”对象上的AttributeError没有属性“ create_user” - Django error: AttributeError at 'Manager' object has no attribute 'create_user'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM