Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Reload the current page with the same request as originally done.
Any change (`select_form`, or any value filled-in in the form) made to
the current page before refresh is discarded.
:raise ValueError: Raised if no refreshable page is loaded, e.g., when
using the shallow ``Browser`` wrapper functions.
:return: Response of the request."""
old_request = self.__state.request
if old_request is None:
raise ValueError('The current page is not refreshable. Either no '
'page is opened or low-level browser methods '
'were used to do so')
resp = self.session.send(old_request)
Browser.add_soup(resp, self.soup_config)
self.__state = _BrowserState(page=resp.soup, url=resp.url,
request=resp.request)
return resp
def get(self, *args, **kwargs):
"""Straightforward wrapper around `requests.Session.get
`__.
:return: `requests.Response
`__
object with a *soup*-attribute added by :func:`add_soup`.
"""
response = self.session.get(*args, **kwargs)
if self.raise_on_404 and response.status_code == 404:
raise LinkNotFoundError()
Browser.add_soup(response, self.soup_config)
return response