From bd4a08e7ce9e4b7a0c49d517ad4600ca84d797f1 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 27 Feb 2018 19:38:19 -0500 Subject: [PATCH] example JavaScript Signed-off-by: Kenneth Reitz --- requests_html.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/requests_html.py b/requests_html.py index 85d5bb6..f1ef240 100644 --- a/requests_html.py +++ b/requests_html.py @@ -238,9 +238,19 @@ class HTML(BaseParser): number of times, after sleeping the specified amount of time. If ``script`` is specified, it will execute the provided JavaScript at - runtime. + runtime. Example: - Returns the return value of ``script``, if any is provided. + script = ''' + () => { + return { + width: document.documentElement.clientWidth, + height: document.documentElement.clientHeight, + deviceScaleFactor: window.devicePixelRatio, + } + } + ''' + + Returns the return value of'the executed ``script``, if any is provided. Warning: the first time you run this method, it will download Chromium into your home directory (``~/.pyppeteer``).