js_snippet param, and it will be executed after the page load will finish.
To encode your JS snippet into the Base64 encoded string, you can use the following tools:
- Python: base64
base64_snippet = base64.b64encode("JS SNIPPET".encode()).decode()
const buffer = new Buffer('JS SNIPPET');
let base64_snippet = buffer.toString('base64');
- PHP: base64_encode
$base64_snippet = base64_encode('JS SNIPPET');
Those examples are only the most commonly used ones. To find out how to do it for your programming language, just Google
base64 encoding <your_programming_language>
JS execution time
Scroll to the bottom of the page and wait 2 seconds.
await new Promise(r => setTimeout(r, 2000));
The API request that scrapes
example.com and executes scrolling to the bottom of the page after the page load looks like the following:
Click a button by ID
Below you can find a helpful tool that makes Base64 encoding for you.
Base64 data encoding
Please, enter your JS code you'd like to run after the page load:
The following result can be inserted in the API request as Base64 encoded JS snippet: