diff --git a/README.md b/README.md index 142139b..2c65589 100644 --- a/README.md +++ b/README.md @@ -187,8 +187,9 @@ session. When you no longer need to use a session you should make sure to close | maxTimeout | Optional, default value 60000. Max timeout to solve the challenge in milliseconds. | | cookies | Optional. Will be used by the headless browser. Eg: `"cookies": [{"name": "cookie1", "value": "value1"}, {"name": "cookie2", "value": "value2"}]`. | | returnOnlyCookies | Optional, default false. Only returns the cookies. Response data, headers and other parts of the response are removed. | +| returnScreenshot | Optional, default false. Captures a screenshot of the final rendered page after all challenges and waits are completed. The screenshot is returned as a Base64-encoded PNG string in the `screenshot` field of the response. | | proxy | Optional, default disabled. Eg: `"proxy": {"url": "http://127.0.0.1:8888"}`. You must include the proxy schema in the URL: `http://`, `socks4://` or `socks5://`. Authorization (username/password) is not supported. (When the `session` parameter is set, the proxy is ignored; a session specific proxy can be set in `sessions.create`.) | -| waitInSeconds | Optional, default none. Length to wait in seconds after solving the challenge, and before returning the results. Useful to allow it to load dynamic content. | +| waitInSeconds | Optional, default none. Length to wait in seconds after solving the challenge, and before returning the results. Useful to allow it to load dynamic content. | > **Warning** > If you want to use Cloudflare clearance cookie in your scripts, make sure you use the FlareSolverr User-Agent too. If they don't match you will see the challenge. diff --git a/src/dtos.py b/src/dtos.py index 402aeca..a051232 100644 --- a/src/dtos.py +++ b/src/dtos.py @@ -10,6 +10,7 @@ class ChallengeResolutionResultT: response: str = None cookies: list = None userAgent: str = None + screenshot: str | None = None def __init__(self, _dict): self.__dict__.update(_dict) @@ -41,6 +42,7 @@ class V1RequestBase(object): url: str = None postData: str = None returnOnlyCookies: bool = None + returnScreenshot: bool = None download: bool = None # deprecated v2.0.0, not used returnRawHtml: bool = None # deprecated v2.0.0, not used waitInSeconds: int = None diff --git a/src/flaresolverr_service.py b/src/flaresolverr_service.py index 7bf3620..0f4a510 100644 --- a/src/flaresolverr_service.py +++ b/src/flaresolverr_service.py @@ -397,6 +397,9 @@ def _evil_logic(req: V1RequestBase, driver: WebDriver, method: str) -> Challenge challenge_res.response = driver.page_source + if req.returnScreenshot: + challenge_res.screenshot = driver.get_screenshot_as_base64() + res.result = challenge_res return res