Provides a simple framework for handling pages that require a redirection with a hope to reduce the necessity for so much boilerplate code. You don’t have to extend this class to handle redirections, but it might make things easier.
Keyword arguments:
One can override this function as an alternative to providing a url_match value via the constructor. If neither is specified, this just returns True.
One can override this function as an alternative to providing a page_match value via the constructor. If neither is specified, this just returns True.
Calls handle_redirect() if there is both a url and page match, otherwise, it simply passes through.
Should return the value given by browser.load_page with the additional arguments, *args and **kwargs (modified if desired). If it returns None or raises a PageRedirectionError, the redirect is canceled. Here’s an example handle_redirect method:
def handle_redirect(plugin, browser, url, parsed, *args, **kwargs):
"For this example, we'll say the plugin's parser is lxml"
return browser.load_page(parsed.xpath("//a")[0].attrib["href"],
*args, **kwargs)
Should return the value given by browser.load_page with the additional arguments, *args and **kwargs (modified if desired). If it returns None or raises a PageRedirectionError, the redirect is canceled. Here’s an example handle_redirect method:
def handle_redirect(plugin, browser, url, parsed, *args, **kwargs):
"For this example, we'll say the plugin's parser is lxml"
return browser.load_page(parsed.xpath("//a")[0].attrib["href"],
*args, **kwargs)
Calls handle_redirect() if there is both a url and page match, otherwise, it simply passes through.
Handles pages using the deprecated html meta refresh feature.