How to use the mechanicalsoup.stateful_browser.StatefulBrowser function in MechanicalSoup

To help you get started, we’ve selected a few MechanicalSoup examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MechanicalSoup / MechanicalSoup / mechanicalsoup / stateful_browser.py View on Github external
def launch_browser(self, soup=None):
        """Launch a browser to display a page, for debugging purposes.

        :param: soup: Page contents to display, supplied as a bs4 soup object.
            Defaults to the current page of the ``StatefulBrowser`` instance.
        """
        if soup is None:
            soup = self.page
        super(StatefulBrowser, self).launch_browser(soup)
github bomquote / transistor / transistor / browsers / splash_browser.py View on Github external
"""

import bs4
import sys
import random
import gevent
from requests import Response
from requests.exceptions import Timeout
from mechanicalsoup.stateful_browser import _BrowserState, StatefulBrowser
from mechanicalsoup.utils import LinkNotFoundError
from mechanicalsoup.form import Form
from transistor.utility.utils import obsolete_setter
from transistor.browsers.mixin import SplashBrowserMixin


class SplashBrowser(StatefulBrowser, SplashBrowserMixin):
    """
    Make a few changes and overrides to enable a mechanicalsoup StatefulBrowser to
    work with Splash alone or Splash + Crawlera.

    Note: `select_form`, `submit` and `submit_selected` need refactored
    to work with Splash. Not useful/broken at the moment.
    """

    retry = 0

    def __init__(self, *args, **kwargs):
        self._set_raw_content(content=b'')
        self._set_status(status='')
        self.__state = _BrowserState()
        self._test_true = False
        self.timeout_exception = False