Adding the option to randomize the OS fingerprints with the StealthyFetcher
This commit is contained in:
@@ -20,7 +20,7 @@ class CamoufoxEngine:
|
||||
block_webrtc: Optional[bool] = False, allow_webgl: Optional[bool] = False, network_idle: Optional[bool] = False, humanize: Optional[Union[bool, float]] = True,
|
||||
timeout: Optional[float] = 30000, page_action: Callable = do_nothing, wait_selector: Optional[str] = None, addons: Optional[List[str]] = None,
|
||||
wait_selector_state: str = 'attached', google_search: Optional[bool] = True, extra_headers: Optional[Dict[str, str]] = None,
|
||||
proxy: Optional[Union[str, Dict[str, str]]] = None, adaptor_arguments: Dict = None
|
||||
proxy: Optional[Union[str, Dict[str, str]]] = None, os_randomize: Optional[bool] = None, adaptor_arguments: Dict = None
|
||||
):
|
||||
"""An engine that utilizes Camoufox library, check the `StealthyFetcher` class for more documentation.
|
||||
|
||||
@@ -35,6 +35,7 @@ class CamoufoxEngine:
|
||||
:param humanize: Humanize the cursor movement. Takes either True or the MAX duration in seconds of the cursor movement. The cursor typically takes up to 1.5 seconds to move across the window.
|
||||
:param allow_webgl: Whether to allow WebGL. To prevent leaks, only use this for special cases.
|
||||
:param network_idle: Wait for the page until there are no network connections for at least 500 ms.
|
||||
:param os_randomize: If enabled, Scrapling will randomize the OS fingerprints used. The default is Scrapling matching the fingerprints with the current OS.
|
||||
:param timeout: The timeout in milliseconds that is used in all operations and waits through the page. The default is 30000
|
||||
:param page_action: Added for automation. A function that takes the `page` object, does the automation you need, then returns `page` again.
|
||||
:param wait_selector: Wait for a specific css selector to be in a specific state.
|
||||
@@ -51,6 +52,7 @@ class CamoufoxEngine:
|
||||
self.allow_webgl = bool(allow_webgl)
|
||||
self.network_idle = bool(network_idle)
|
||||
self.google_search = bool(google_search)
|
||||
self.os_randomize = bool(os_randomize)
|
||||
self.extra_headers = extra_headers or {}
|
||||
self.proxy = construct_proxy_dict(proxy)
|
||||
self.addons = addons or []
|
||||
@@ -73,15 +75,15 @@ class CamoufoxEngine:
|
||||
:return: A Response object with `url`, `text`, `content`, `status`, `reason`, `encoding`, `cookies`, `headers`, `request_headers`, and the `adaptor` class for parsing, of course.
|
||||
"""
|
||||
with Camoufox(
|
||||
headless=self.headless,
|
||||
block_images=self.block_images, # Careful! it makes some websites doesn't finish loading at all like stackoverflow even in headful
|
||||
os=get_os_name(),
|
||||
block_webrtc=self.block_webrtc,
|
||||
allow_webgl=self.allow_webgl,
|
||||
addons=self.addons,
|
||||
humanize=self.humanize,
|
||||
proxy=self.proxy,
|
||||
i_know_what_im_doing=True, # To turn warnings off with user configurations
|
||||
addons=self.addons,
|
||||
headless=self.headless,
|
||||
humanize=self.humanize,
|
||||
i_know_what_im_doing=True, # To turn warnings off with the user configurations
|
||||
allow_webgl=self.allow_webgl,
|
||||
block_webrtc=self.block_webrtc,
|
||||
block_images=self.block_images, # Careful! it makes some websites doesn't finish loading at all like stackoverflow even in headful
|
||||
os=None if self.os_randomize else get_os_name(),
|
||||
) as browser:
|
||||
page = browser.new_page()
|
||||
page.set_default_navigation_timeout(self.timeout)
|
||||
|
||||
Reference in New Issue
Block a user