woob.browser.switch
¶
- exception SiteSwitch(name)[source]¶
Bases:
Exception
Exception to raise to switch to another Browser.
- class SwitchingBrowser(*args, **kwargs)[source]¶
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.
- KEEP_ATTRS = ()¶
Pass the values stored in __states__
- class SwitchingBrowserWithState(*args, **kwargs)[source]¶
Bases:
SwitchingBrowser
Use state to transmit knowledge of last browser used during a previous sync to later start on the same browser