example JavaScript

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
This commit is contained in:
2018-02-27 19:38:19 -05:00
parent bff28e3dbd
commit bd4a08e7ce
+12 -2
View File
@@ -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``).