Search code examples
pythonhttp-authenticationspynner

Using set_http_authentication_callback(self, callback)


I'm using a spynner package fo Python and when I try to load a page like this:

sb = spynner.Browser()

sb.load(URL)

I have an error: Traceback (most recent call last): File "C:\Python27\lib\site-packages\spynner-1.10-py2.7.egg\spynner\browser.py", line 207, in _on_authentication_required if not self._http_authentication_callback: AttributeError: 'Browser' object has no attribute '_http_authentication_callback' QWaitCondition: Destroyed while threads are still waiting

I think that I should use a function: set_http_authentication_callback(self, callback) before I use a load function. But I don't know how. Can anybody show me an example how to use this function??

Any help is much appreciated!


Solution

  • First, declare a function named, for example http_auth_callback in the scope in which you are working(ex. in your class or globally)

    def http_auth_callback(arguments):
        print dir(arguments)
    

    Try something like this:

    sb = spynner.Browser()
    
    sb.set_http_authentication_callback(http_auth_callback) # if using global scope
    sb.set_http_authentication_callback(self.http_auth_callback) # if inside a class and the callback function is declared as a method
    
    sb.load(URL)