diff --git a/requests_html.py b/requests_html.py
index ea8f3bd..a92f24f 100644
--- a/requests_html.py
+++ b/requests_html.py
@@ -486,7 +486,7 @@ def __next__(self):
def add_next_symbol(self, next_symbol):
self.next_symbol.append(next_symbol)
- def render(self, retries: int = 8, script: str = None, wait: float = 0.2, scrolldown=False, sleep: int = 0, reload: bool = True, timeout: Union[float, int] = 8.0, keep_page: bool = False):
+ def render(self, retries: int = 8, script: str = None, wait: float = 0.2, scrolldown=False, sleep: int = 0, reload: bool = True, timeout: Union[float, int] = 8.0, keep_page: bool = False, headers: dict = {}):
"""Reloads the response in Chromium, and replaces HTML content
with an updated version, with JavaScript executed.
@@ -497,6 +497,7 @@ def render(self, retries: int = 8, script: str = None, wait: float = 0.2, scroll
:param sleep: Integer, if provided, of how many long to sleep after initial render.
:param reload: If ``False``, content will not be loaded from the browser, but will be provided from memory.
:param keep_page: If ``True`` will allow you to interact with the browser page through ``r.html.page``.
+ :param headers: The additional headers added to the page.
If ``scrolldown`` is specified, the page will scrolldown the specified
number of times, after sleeping the specified amount of time
@@ -537,6 +538,10 @@ async def _async_render(*, url: str, script: str = None, scrolldown, sleep: int,
try:
page = await self.session.browser.newPage()
+ # Add additional headers to the page
+ if headers:
+ await page.setExtraHTTPHeaders(headers)
+
# Wait before rendering the page, to prevent timeouts.
await asyncio.sleep(wait)