Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def post(self, *args, **kwargs):
"""Straightforward wrapper around `requests.Session.post
`__.
:return: `requests.Response
`__
object with a *soup*-attribute added by :func:`add_soup`.
"""
response = self.session.post(*args, **kwargs)
Browser.add_soup(response, self.soup_config)
return response
from .utils import LinkNotFoundError
from .form import Form
import sys
import re
import bs4
class _BrowserState:
def __init__(self, page=None, url=None, form=None, request=None):
self.page = page
self.url = url
self.form = form
self.request = request
class StatefulBrowser(Browser):
"""An extension of :class:`Browser` that stores the browser's state
and provides many convenient functions for interacting with HTML elements.
It is the primary tool in MechanicalSoup for interfacing with websites.
:param session: Attach a pre-existing requests Session instead of
constructing a new one.
:param soup_config: Configuration passed to BeautifulSoup to affect
the way HTML is parsed. Defaults to ``{'features': 'lxml'}``.
If overriden, it is highly recommended to `specify a parser
`__.
Otherwise, BeautifulSoup will issue a warning and pick one for
you, but the parser it chooses may be different on different
machines.
:param requests_adapters: Configuration passed to requests, to affect
the way HTTP requests are performed.
:param raise_on_404: If True, raise :class:`LinkNotFoundError`