weboob.browser.switch

exception weboob.browser.switch.SiteSwitch(name)

Bases: exceptions.Exception

Exception to raise to switch to another Browser.

Parameters:name (str) – key of the SwitchingBrowser.BROWSERS dict to indicate the new browser class to use
class weboob.browser.switch.SwitchingBrowser(*args, **kwargs)

Bases: object

Proxy browser to use multiple (exclusive) browsers.

When some sites have mutually exclusive sub-sites, it may be better to split a browser in multiple browsers. If it’s not possible to know in advance what browser should be used, the SwitchingBrowser can help.

Multiple browsers should be configured in the BROWSERS attribute as a dict. When first used, SwitchingBrowser will instanciate the browser class with the ‘main’ key and proxy all method calls to it. If that browser raises SiteSwitch exception, another browser (associated to the exception key parameter) will be instanciated and will be used to retry the call which failed.

BROWSERS = None

dict association keys to browser classes.

It should contain a ‘main’ key for the first browser class to use.

KEEP_SESSION = False

Whether to pass the requests.session.Session between browsers.

set_browser(name)