Javascript execution

How to execute your own Javascript code in the scraped page context.

Executing custom Javascript#

You can pass your custom Javascript code to run in the browser context with using this param, and it will be executed after page load finished. This can be used for interaction with a page, like scrolling, pressing a button, etc. Your Javascript snippet must be Base64 encoded.

JS execution time#

Every URL fetching time is limited to 30 seconds, so be aware of it while writing your Javascript snippet.

Examples#

Scroll to the bottom of the page and wait 2 seconds.

window.scrollTo(0,document.body.scrollHeight);
await new Promise(r => setTimeout(r, 2000));

Click a button.

document.getElementById('button-id').click();

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: