MCPcopy Create free account
hub / github.com/psf/requests-html / HTMLSession

Class HTMLSession

requests_html.py:719–737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

717
718
719class HTMLSession(BaseSession):
720
721 def __init__(self, **kwargs):
722 super(HTMLSession, self).__init__(**kwargs)
723
724 @property
725 def browser(self):
726 if not hasattr(self, "_browser"):
727 self.loop = asyncio.get_event_loop()
728 if self.loop.is_running():
729 raise RuntimeError("Cannot use HTMLSession within an existing event loop. Use AsyncHTMLSession instead.")
730 self._browser = self.loop.run_until_complete(super().browser)
731 return self._browser
732
733 def close(self):
734 """ If a browser was created close it first. """
735 if hasattr(self, "_browser"):
736 self.loop.run_until_complete(self._browser.close())
737 super().close()
738
739
740class AsyncHTMLSession(BaseSession):

Callers 5

test_browser_sessionFunction · 0.90
test_internet.pyFile · 0.90
__init__Method · 0.85

Calls

no outgoing calls

Tested by 2

test_browser_sessionFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…