Screenshot functions#
Functions that take JPEG screenshots and return a base64 string (without the data: prefix) that you
can save, send, or pass to a captcha-solving function or an AI.
If you need a data URL, add data:image/jpeg;base64, in front of the returned string yourself.
CapturePage#
Captures the part of the page currently visible on screen, not the whole long page. To get the part below, scroll down and capture again.
Parameters
| Name | Description |
|---|---|
quality |
JPEG quality from 1 to 100. Default 80; lower it to make the string much smaller. |
Returns
The base64 string of the JPEG image, or null if the capture failed.
Examples
CaptureArea#
Captures a rectangular area of the visible part of the page. x1, y1 is the top-left corner and
x2, y2 is the bottom-right corner (not the width and height).
Parameters
| Name | Description |
|---|---|
x1 |
x coordinate of the top-left corner, in pixels. |
y1 |
y coordinate of the top-left corner, in pixels. |
x2 |
x coordinate of the bottom-right corner; must be greater than x1. The width of the captured area is x2 - x1. |
y2 |
y coordinate of the bottom-right corner; must be greater than y1. The height of the captured area is y2 - y1. |
quality |
JPEG quality from 1 to 100. Default 80. |
Returns
The base64 string of the JPEG image, or null if the capture failed (for example when x2 is
smaller than x1).
Examples
Note
To capture exactly one element, use CaptureElement: it finds the element's
position and scrolls to it for you.
CaptureElement#
Captures a single element by CSS selector, for example a captcha image. Any element works, not only
img tags. The function scrolls to the element before capturing. If several elements match, it
captures the first visible one.
Parameters
| Name | Description |
|---|---|
selector |
A CSS selector, for example "#image_captcha". |
quality |
JPEG quality from 1 to 100. Default 80. |
frameSearch |
Condition for finding the iframe that contains the element; leave it empty for the main frame. See Iframes, selectors and waiting. |
frameSearchType |
How to match frameSearch: "src-starts", "src-ends", "src-equals", "src-contains", "src-regex" or "frame-path". Required when you use frameSearch: if you leave it empty, the function works on the main frame. |
Returns
The base64 string of the JPEG image, or null when no visible element matches or the capture
failed. With an empty or non-string selector it returns undefined. Check the result before you
use it.