From a1fd5ddc7e0d77f1a487df9d87f36a626b0c1777 Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Wed, 6 Nov 2024 20:18:44 +0200 Subject: [PATCH] Correcting `headless` argument type --- scrapling/core/_types.py | 2 +- scrapling/fetchers.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scrapling/core/_types.py b/scrapling/core/_types.py index f832320..f46dad4 100644 --- a/scrapling/core/_types.py +++ b/scrapling/core/_types.py @@ -3,7 +3,7 @@ Type definitions for type checking purposes. """ from typing import ( - Dict, Optional, Union, Callable, Any, List, Tuple, Pattern, Generator, Iterable, Type, TYPE_CHECKING + Dict, Optional, Union, Callable, Any, List, Tuple, Pattern, Generator, Iterable, Type, TYPE_CHECKING, Literal ) try: diff --git a/scrapling/fetchers.py b/scrapling/fetchers.py index 58ba896..835a8e4 100644 --- a/scrapling/fetchers.py +++ b/scrapling/fetchers.py @@ -1,4 +1,4 @@ -from scrapling.core._types import Dict, Optional, Union, Callable, List +from scrapling.core._types import Dict, Optional, Union, Callable, List, Literal from scrapling.engines.toolbelt import Response, BaseFetcher, do_nothing from scrapling.engines import CamoufoxEngine, PlaywrightEngine, StaticEngine, check_if_engine_usable @@ -69,7 +69,7 @@ class StealthyFetcher(BaseFetcher): Other added flavors include setting the faked OS fingerprints to match the user's OS and the referer of every request is set as if this request came from Google's search of this URL's domain. """ def fetch( - self, url: str, headless: Union[bool, str] = True, block_images: Optional[bool] = False, disable_resources: Optional[bool] = False, + self, url: str, headless: Optional[Union[bool, Literal['virtual']]] = True, block_images: Optional[bool] = False, disable_resources: Optional[bool] = False, block_webrtc: Optional[bool] = False, allow_webgl: Optional[bool] = False, network_idle: Optional[bool] = False, addons: Optional[List[str]] = None, timeout: Optional[float] = 30000, page_action: Callable = do_nothing, wait_selector: Optional[str] = None, humanize: Optional[Union[bool, float]] = True, wait_selector_state: str = 'attached', @@ -77,7 +77,7 @@ class StealthyFetcher(BaseFetcher): """ Opens up a browser and do your request based on your chosen options below. :param url: Target url. - :param headless: Run the browser in headless/hidden (default), virtual screen mode, or headful/visible mode. + :param headless: Run the browser in headless/hidden (default), 'virtual' screen mode, or headful/visible mode. :param block_images: Prevent the loading of images through Firefox preferences. This can help save your proxy usage but be careful with this option as it makes some websites never finish loading. :param disable_resources: Drop requests of unnecessary resources for speed boost. It depends but it made requests ~25% faster in my tests for some websites.