Fetchers Classes¶
Here's the reference information for all fetcher-type classes' parameters, attributes, and methods.
You can import all of them directly like below:
from scrapling.fetchers import (
Fetcher, AsyncFetcher, StealthyFetcher, DynamicFetcher,
FetcherSession, AsyncStealthySession, StealthySession, DynamicSession, AsyncDynamicSession
)
scrapling.fetchers.Fetcher
¶
Bases: BaseFetcher
flowchart TD
scrapling.fetchers.Fetcher[Fetcher]
scrapling.engines.toolbelt.custom.BaseFetcher[BaseFetcher]
scrapling.engines.toolbelt.custom.BaseFetcher --> scrapling.fetchers.Fetcher
click scrapling.fetchers.Fetcher href "" "scrapling.fetchers.Fetcher"
click scrapling.engines.toolbelt.custom.BaseFetcher href "" "scrapling.engines.toolbelt.custom.BaseFetcher"
A basic Fetcher class type that can only do basic GET, POST, PUT, and DELETE HTTP requests based on curl_cffi.
Source code in scrapling/engines/toolbelt/custom.py
parser_keywords
class-attribute
instance-attribute
¶
parser_keywords = (
"huge_tree",
"adaptive",
"storage",
"keep_cdata",
"storage_args",
"keep_comments",
"adaptive_domain",
)
display_config
classmethod
¶
Source code in scrapling/engines/toolbelt/custom.py
configure
classmethod
¶
Set multiple arguments for the parser at once globally
| PARAMETER | DESCRIPTION |
|---|---|
kwargs
|
The keywords can be any arguments of the following: huge_tree, keep_comments, keep_cdata, adaptive, storage, storage_args, adaptive_domain
DEFAULT:
|
Source code in scrapling/engines/toolbelt/custom.py
get
classmethod
¶
post
classmethod
¶
put
classmethod
¶
scrapling.fetchers.AsyncFetcher
¶
Bases: BaseFetcher
flowchart TD
scrapling.fetchers.AsyncFetcher[AsyncFetcher]
scrapling.engines.toolbelt.custom.BaseFetcher[BaseFetcher]
scrapling.engines.toolbelt.custom.BaseFetcher --> scrapling.fetchers.AsyncFetcher
click scrapling.fetchers.AsyncFetcher href "" "scrapling.fetchers.AsyncFetcher"
click scrapling.engines.toolbelt.custom.BaseFetcher href "" "scrapling.engines.toolbelt.custom.BaseFetcher"
A basic Fetcher class type that can only do basic GET, POST, PUT, and DELETE HTTP requests based on curl_cffi.
Source code in scrapling/engines/toolbelt/custom.py
parser_keywords
class-attribute
instance-attribute
¶
parser_keywords = (
"huge_tree",
"adaptive",
"storage",
"keep_cdata",
"storage_args",
"keep_comments",
"adaptive_domain",
)
display_config
classmethod
¶
Source code in scrapling/engines/toolbelt/custom.py
configure
classmethod
¶
Set multiple arguments for the parser at once globally
| PARAMETER | DESCRIPTION |
|---|---|
kwargs
|
The keywords can be any arguments of the following: huge_tree, keep_comments, keep_cdata, adaptive, storage, storage_args, adaptive_domain
DEFAULT:
|
Source code in scrapling/engines/toolbelt/custom.py
get
classmethod
¶
post
classmethod
¶
put
classmethod
¶
scrapling.fetchers.DynamicFetcher
¶
Bases: BaseFetcher
flowchart TD
scrapling.fetchers.DynamicFetcher[DynamicFetcher]
scrapling.engines.toolbelt.custom.BaseFetcher[BaseFetcher]
scrapling.engines.toolbelt.custom.BaseFetcher --> scrapling.fetchers.DynamicFetcher
click scrapling.fetchers.DynamicFetcher href "" "scrapling.fetchers.DynamicFetcher"
click scrapling.engines.toolbelt.custom.BaseFetcher href "" "scrapling.engines.toolbelt.custom.BaseFetcher"
A Fetcher that provide many options to fetch/load websites' pages through chromium-based browsers.
Source code in scrapling/engines/toolbelt/custom.py
parser_keywords
class-attribute
instance-attribute
¶
parser_keywords = (
"huge_tree",
"adaptive",
"storage",
"keep_cdata",
"storage_args",
"keep_comments",
"adaptive_domain",
)
display_config
classmethod
¶
Source code in scrapling/engines/toolbelt/custom.py
configure
classmethod
¶
Set multiple arguments for the parser at once globally
| PARAMETER | DESCRIPTION |
|---|---|
kwargs
|
The keywords can be any arguments of the following: huge_tree, keep_comments, keep_cdata, adaptive, storage, storage_args, adaptive_domain
DEFAULT:
|
Source code in scrapling/engines/toolbelt/custom.py
fetch
classmethod
¶
Opens up a browser and do your request based on your chosen options below.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
Target url.
TYPE:
|
headless
|
Run the browser in headless/hidden (default), or headful/visible mode.
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
|
blocked_domains
|
A set of domain names to block requests to. Subdomains are also matched (e.g.,
|
block_ads
|
Block requests to ~3,500 known ad/tracking domains. Can be combined with
|
dns_over_https
|
Route DNS queries through Cloudflare's DNS-over-HTTPS to prevent DNS leaks when using proxies.
|
useragent
|
Pass a useragent string to be used. Otherwise the fetcher will generate a real Useragent of the same browser and use it.
|
cookies
|
Set cookies for the next request.
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
|
load_dom
|
Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
|
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the Response object.
|
page_action
|
Added for automation. A function that takes the
|
page_setup
|
A function that takes the
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
|
init_script
|
An absolute path to a JavaScript file to be executed on page creation with this request.
|
locale
|
Set the locale for the browser if wanted. Defaults to the system default locale.
|
wait_selector_state
|
The state to wait for the selector given with
|
real_chrome
|
If you have a Chrome browser installed on your device, enable this, and the Fetcher will launch an instance of your browser and use it.
|
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
|
extra_headers
|
A dictionary of extra headers to add to the request.
|
proxy
|
The proxy to be used with requests, it can be a string or a dictionary with the keys 'server', 'username', and 'password' only.
|
extra_flags
|
A list of additional browser flags to pass to the browser on launch.
|
selector_config
|
The arguments that will be passed in the end while creating the final Selector's class.
|
additional_args
|
Additional arguments to be passed to Playwright's context as additional settings.
|
| RETURNS | DESCRIPTION |
|---|---|
Response
|
A |
Source code in scrapling/fetchers/chrome.py
async_fetch
async
classmethod
¶
Opens up a browser and do your request based on your chosen options below.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
Target url.
TYPE:
|
headless
|
Run the browser in headless/hidden (default), or headful/visible mode.
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
|
blocked_domains
|
A set of domain names to block requests to. Subdomains are also matched (e.g.,
|
block_ads
|
Block requests to ~3,500 known ad/tracking domains. Can be combined with
|
dns_over_https
|
Route DNS queries through Cloudflare's DNS-over-HTTPS to prevent DNS leaks when using proxies.
|
useragent
|
Pass a useragent string to be used. Otherwise the fetcher will generate a real Useragent of the same browser and use it.
|
cookies
|
Set cookies for the next request.
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
|
load_dom
|
Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
|
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the Response object.
|
page_action
|
Added for automation. A function that takes the
|
page_setup
|
A function that takes the
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
|
init_script
|
An absolute path to a JavaScript file to be executed on page creation with this request.
|
locale
|
Set the locale for the browser if wanted. Defaults to the system default locale.
|
wait_selector_state
|
The state to wait for the selector given with
|
real_chrome
|
If you have a Chrome browser installed on your device, enable this, and the Fetcher will launch an instance of your browser and use it.
|
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
|
extra_headers
|
A dictionary of extra headers to add to the request.
|
proxy
|
The proxy to be used with requests, it can be a string or a dictionary with the keys 'server', 'username', and 'password' only.
|
extra_flags
|
A list of additional browser flags to pass to the browser on launch.
|
selector_config
|
The arguments that will be passed in the end while creating the final Selector's class.
|
additional_args
|
Additional arguments to be passed to Playwright's context as additional settings.
|
| RETURNS | DESCRIPTION |
|---|---|
Response
|
A |
Source code in scrapling/fetchers/chrome.py
scrapling.fetchers.StealthyFetcher
¶
Bases: BaseFetcher
flowchart TD
scrapling.fetchers.StealthyFetcher[StealthyFetcher]
scrapling.engines.toolbelt.custom.BaseFetcher[BaseFetcher]
scrapling.engines.toolbelt.custom.BaseFetcher --> scrapling.fetchers.StealthyFetcher
click scrapling.fetchers.StealthyFetcher href "" "scrapling.fetchers.StealthyFetcher"
click scrapling.engines.toolbelt.custom.BaseFetcher href "" "scrapling.engines.toolbelt.custom.BaseFetcher"
A Fetcher class type which is a completely stealthy built on top of Chromium.
It works as real browsers passing almost all online tests/protections with many customization options.
Source code in scrapling/engines/toolbelt/custom.py
parser_keywords
class-attribute
instance-attribute
¶
parser_keywords = (
"huge_tree",
"adaptive",
"storage",
"keep_cdata",
"storage_args",
"keep_comments",
"adaptive_domain",
)
display_config
classmethod
¶
Source code in scrapling/engines/toolbelt/custom.py
configure
classmethod
¶
Set multiple arguments for the parser at once globally
| PARAMETER | DESCRIPTION |
|---|---|
kwargs
|
The keywords can be any arguments of the following: huge_tree, keep_comments, keep_cdata, adaptive, storage, storage_args, adaptive_domain
DEFAULT:
|
Source code in scrapling/engines/toolbelt/custom.py
fetch
classmethod
¶
Opens up a browser and do your request based on your chosen options below.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
Target url.
TYPE:
|
headless
|
Run the browser in headless/hidden (default), or headful/visible mode.
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
|
blocked_domains
|
A set of domain names to block requests to. Subdomains are also matched (e.g.,
|
block_ads
|
Block requests to ~3,500 known ad/tracking domains. Can be combined with
|
dns_over_https
|
Route DNS queries through Cloudflare's DNS-over-HTTPS to prevent DNS leaks when using proxies.
|
useragent
|
Pass a useragent string to be used. Otherwise the fetcher will generate a real Useragent of the same browser and use it.
|
cookies
|
Set cookies for the next request.
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
|
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the
|
page_action
|
Added for automation. A function that takes the
|
page_setup
|
A function that takes the
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
|
init_script
|
An absolute path to a JavaScript file to be executed on page creation for all pages in this session.
|
locale
|
Specify user locale, for example,
|
timezone_id
|
Changes the timezone of the browser. Defaults to the system timezone.
|
wait_selector_state
|
The state to wait for the selector given with
|
solve_cloudflare
|
Solves all types of the Cloudflare's Turnstile/Interstitial challenges before returning the response to you.
|
real_chrome
|
If you have a Chrome browser installed on your device, enable this, and the Fetcher will launch an instance of your browser and use it.
|
hide_canvas
|
Add random noise to canvas operations to prevent fingerprinting.
|
block_webrtc
|
Forces WebRTC to respect proxy settings to prevent local IP address leak.
|
allow_webgl
|
Enabled by default. Disabling it disables WebGL and WebGL 2.0 support entirely. Disabling WebGL is not recommended as many WAFs now check if WebGL is enabled.
|
load_dom
|
Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
|
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
|
extra_headers
|
A dictionary of extra headers to add to the request. The referer set by
|
proxy
|
The proxy to be used with requests, it can be a string or a dictionary with the keys 'server', 'username', and 'password' only.
|
user_data_dir
|
Path to a User Data Directory, which stores browser session data like cookies and local storage. The default is to create a temporary directory.
|
extra_flags
|
A list of additional browser flags to pass to the browser on launch.
|
selector_config
|
The arguments that will be passed in the end while creating the final Selector's class.
|
additional_args
|
Additional arguments to be passed to Playwright's context as additional settings, and it takes higher priority than Scrapling's settings.
|
| RETURNS | DESCRIPTION |
|---|---|
Response
|
A |
Source code in scrapling/fetchers/stealth_chrome.py
async_fetch
async
classmethod
¶
Opens up a browser and do your request based on your chosen options below.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
Target url.
TYPE:
|
headless
|
Run the browser in headless/hidden (default), or headful/visible mode.
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
|
blocked_domains
|
A set of domain names to block requests to. Subdomains are also matched (e.g.,
|
block_ads
|
Block requests to ~3,500 known ad/tracking domains. Can be combined with
|
dns_over_https
|
Route DNS queries through Cloudflare's DNS-over-HTTPS to prevent DNS leaks when using proxies.
|
useragent
|
Pass a useragent string to be used. Otherwise the fetcher will generate a real Useragent of the same browser and use it.
|
cookies
|
Set cookies for the next request.
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
|
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the
|
page_action
|
Added for automation. A function that takes the
|
page_setup
|
A function that takes the
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
|
init_script
|
An absolute path to a JavaScript file to be executed on page creation for all pages in this session.
|
locale
|
Specify user locale, for example,
|
timezone_id
|
Changes the timezone of the browser. Defaults to the system timezone.
|
wait_selector_state
|
The state to wait for the selector given with
|
solve_cloudflare
|
Solves all types of the Cloudflare's Turnstile/Interstitial challenges before returning the response to you.
|
real_chrome
|
If you have a Chrome browser installed on your device, enable this, and the Fetcher will launch an instance of your browser and use it.
|
hide_canvas
|
Add random noise to canvas operations to prevent fingerprinting.
|
block_webrtc
|
Forces WebRTC to respect proxy settings to prevent local IP address leak.
|
allow_webgl
|
Enabled by default. Disabling it disables WebGL and WebGL 2.0 support entirely. Disabling WebGL is not recommended as many WAFs now check if WebGL is enabled.
|
load_dom
|
Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
|
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
|
extra_headers
|
A dictionary of extra headers to add to the request. The referer set by
|
proxy
|
The proxy to be used with requests, it can be a string or a dictionary with the keys 'server', 'username', and 'password' only.
|
user_data_dir
|
Path to a User Data Directory, which stores browser session data like cookies and local storage. The default is to create a temporary directory.
|
extra_flags
|
A list of additional browser flags to pass to the browser on launch.
|
selector_config
|
The arguments that will be passed in the end while creating the final Selector's class.
|
additional_args
|
Additional arguments to be passed to Playwright's context as additional settings, and it takes higher priority than Scrapling's settings.
|
| RETURNS | DESCRIPTION |
|---|---|
Response
|
A |
Source code in scrapling/fetchers/stealth_chrome.py
Session Classes¶
HTTP Sessions¶
scrapling.fetchers.FetcherSession
¶
FetcherSession(
impersonate="chrome",
http3=False,
stealthy_headers=True,
proxies=None,
proxy=None,
proxy_auth=None,
timeout=30,
headers=None,
retries=3,
retry_delay=1,
follow_redirects="safe",
max_redirects=30,
verify=True,
cert=None,
selector_config=None,
proxy_rotator=None,
)
A factory context manager that provides configured Fetcher sessions.
When this manager is used in a 'with' or 'async with' block, it yields a new session configured with the manager's defaults. A single instance of this manager should ideally be used for one active session at a time (or sequentially). Re-entering a context with the same manager instance while a session is already active is disallowed.
| PARAMETER | DESCRIPTION |
|---|---|
impersonate
|
Browser version to impersonate. Can be a single browser string or a list of browser strings for random selection. (Default: latest available Chrome version)
TYPE:
|
http3
|
Whether to use HTTP3. Defaults to False. It might be problematic if used it with
TYPE:
|
stealthy_headers
|
If enabled (default), it creates and adds real browser headers. It also sets a Google referer header.
TYPE:
|
proxies
|
Dict of proxies to use. Format: {"http": proxy_url, "https": proxy_url}. |
proxy
|
Proxy URL to use. Format: "http://username:password@localhost:8030".
Cannot be used together with the
TYPE:
|
proxy_auth
|
HTTP basic auth for proxy, tuple of (username, password). |
timeout
|
Number of seconds to wait before timing out. |
headers
|
Headers to include in the session with every request. |
retries
|
Number of retry attempts. Defaults to 3.
TYPE:
|
retry_delay
|
Number of seconds to wait between retry attempts. Defaults to 1 second.
TYPE:
|
follow_redirects
|
Whether to follow redirects. Defaults to "safe", which follows redirects but rejects those targeting internal/private IPs (SSRF protection). Pass True to follow all redirects without restriction.
TYPE:
|
max_redirects
|
Maximum number of redirects. Default 30, use -1 for unlimited.
TYPE:
|
verify
|
Whether to verify HTTPS certificates. Defaults to True.
TYPE:
|
cert
|
Tuple of (cert, key) filenames for the client certificate. |
selector_config
|
Arguments passed when creating the final Selector class.
TYPE:
|
proxy_rotator
|
A ProxyRotator instance for automatic proxy rotation.
TYPE:
|
Source code in scrapling/engines/static.py
__slots__
class-attribute
instance-attribute
¶
__slots__ = (
"_default_impersonate",
"_stealth",
"_default_proxies",
"_default_proxy",
"_default_proxy_auth",
"_default_timeout",
"_default_headers",
"_default_retries",
"_default_retry_delay",
"_default_follow_redirects",
"_default_max_redirects",
"_default_verify",
"_default_cert",
"_default_http3",
"selector_config",
"_client",
"_is_alive",
"_proxy_rotator",
)
__enter__
¶
Creates and returns a new synchronous Fetcher Session
Source code in scrapling/engines/static.py
__exit__
¶
Source code in scrapling/engines/static.py
__aenter__
async
¶
Creates and returns a new asynchronous Session.
Source code in scrapling/engines/static.py
__aexit__
async
¶
Source code in scrapling/engines/static.py
Stealth Sessions¶
scrapling.fetchers.StealthySession
¶
Bases: SyncSession, StealthySessionMixin
flowchart TD
scrapling.fetchers.StealthySession[StealthySession]
scrapling.engines._browsers._base.SyncSession[SyncSession]
scrapling.engines._browsers._base.StealthySessionMixin[StealthySessionMixin]
scrapling.engines._browsers._base.BaseSessionMixin[BaseSessionMixin]
scrapling.engines._browsers._base.SyncSession --> scrapling.fetchers.StealthySession
scrapling.engines._browsers._base.StealthySessionMixin --> scrapling.fetchers.StealthySession
scrapling.engines._browsers._base.BaseSessionMixin --> scrapling.engines._browsers._base.StealthySessionMixin
click scrapling.fetchers.StealthySession href "" "scrapling.fetchers.StealthySession"
click scrapling.engines._browsers._base.SyncSession href "" "scrapling.engines._browsers._base.SyncSession"
click scrapling.engines._browsers._base.StealthySessionMixin href "" "scrapling.engines._browsers._base.StealthySessionMixin"
click scrapling.engines._browsers._base.BaseSessionMixin href "" "scrapling.engines._browsers._base.BaseSessionMixin"
A Stealthy Browser session manager with page pooling.
A Browser session manager with page pooling, it's using a persistent browser Context by default with a temporary user profile directory.
| PARAMETER | DESCRIPTION |
|---|---|
headless
|
Run the browser in headless/hidden (default), or headful/visible mode.
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
|
blocked_domains
|
A set of domain names to block requests to. Subdomains are also matched (e.g.,
|
useragent
|
Pass a useragent string to be used. Otherwise the fetcher will generate a real Useragent of the same browser and use it.
|
cookies
|
Set cookies for the next request.
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
|
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the
|
page_action
|
Added for automation. A function that takes the
|
page_setup
|
A function that takes the
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
|
init_script
|
An absolute path to a JavaScript file to be executed on page creation for all pages in this session.
|
locale
|
Specify user locale, for example,
|
timezone_id
|
Changes the timezone of the browser. Defaults to the system timezone.
|
wait_selector_state
|
The state to wait for the selector given with
|
solve_cloudflare
|
Solves all types of the Cloudflare's Turnstile/Interstitial challenges before returning the response to you.
|
real_chrome
|
If you have a Chrome browser installed on your device, enable this, and the Fetcher will launch an instance of your browser and use it.
|
hide_canvas
|
Add random noise to canvas operations to prevent fingerprinting.
|
block_webrtc
|
Forces WebRTC to respect proxy settings to prevent local IP address leak.
|
allow_webgl
|
Enabled by default. Disabling it disables WebGL and WebGL 2.0 support entirely. Disabling WebGL is not recommended as many WAFs now check if WebGL is enabled.
|
load_dom
|
Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
|
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
|
extra_headers
|
A dictionary of extra headers to add to the request. The referer set by
|
proxy
|
The proxy to be used with requests, it can be a string or a dictionary with the keys 'server', 'username', and 'password' only.
|
user_data_dir
|
Path to a User Data Directory, which stores browser session data like cookies and local storage. The default is to create a temporary directory.
|
extra_flags
|
A list of additional browser flags to pass to the browser on launch.
|
selector_config
|
The arguments that will be passed in the end while creating the final Selector's class.
|
additional_args
|
Additional arguments to be passed to Playwright's context as additional settings, and it takes higher priority than Scrapling's settings.
|
Source code in scrapling/engines/_browsers/_stealth.py
__slots__
class-attribute
instance-attribute
¶
__slots__ = (
"_config",
"_context_options",
"_browser_options",
"_user_data_dir",
"_headers_keys",
"max_pages",
"page_pool",
"_max_wait_for_page",
"playwright",
"context",
)
__validate_routine__
¶
Source code in scrapling/engines/_browsers/_base.py
__generate_options__
¶
Source code in scrapling/engines/_browsers/_base.py
__validate__
¶
Source code in scrapling/engines/_browsers/_base.py
close
¶
Close all resources
Source code in scrapling/engines/_browsers/_base.py
__enter__
¶
__exit__
¶
get_pool_stats
¶
Get statistics about the current page pool
start
¶
Create a browser for this instance and context.
Source code in scrapling/engines/_browsers/_stealth.py
fetch
¶
Opens up the browser and do your request based on your chosen options.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The Target url.
TYPE:
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
|
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the
|
page_action
|
Added for automation. A function that takes the
|
page_setup
|
A function that takes the
|
extra_headers
|
A dictionary of extra headers to add to the request. The referer set by
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
|
blocked_domains
|
A set of domain names to block requests to. Subdomains are also matched (e.g.,
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
|
wait_selector_state
|
The state to wait for the selector given with
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
|
load_dom
|
Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
|
solve_cloudflare
|
Solves all types of the Cloudflare's Turnstile/Interstitial challenges before returning the response to you.
|
selector_config
|
The arguments that will be passed in the end while creating the final Selector's class.
|
proxy
|
Static proxy to override rotator and session proxy. A new browser context will be created and used with it.
|
| RETURNS | DESCRIPTION |
|---|---|
Response
|
A |
Source code in scrapling/engines/_browsers/_stealth.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
scrapling.fetchers.AsyncStealthySession
¶
Bases: AsyncSession, StealthySessionMixin
flowchart TD
scrapling.fetchers.AsyncStealthySession[AsyncStealthySession]
scrapling.engines._browsers._base.AsyncSession[AsyncSession]
scrapling.engines._browsers._base.StealthySessionMixin[StealthySessionMixin]
scrapling.engines._browsers._base.BaseSessionMixin[BaseSessionMixin]
scrapling.engines._browsers._base.AsyncSession --> scrapling.fetchers.AsyncStealthySession
scrapling.engines._browsers._base.StealthySessionMixin --> scrapling.fetchers.AsyncStealthySession
scrapling.engines._browsers._base.BaseSessionMixin --> scrapling.engines._browsers._base.StealthySessionMixin
click scrapling.fetchers.AsyncStealthySession href "" "scrapling.fetchers.AsyncStealthySession"
click scrapling.engines._browsers._base.AsyncSession href "" "scrapling.engines._browsers._base.AsyncSession"
click scrapling.engines._browsers._base.StealthySessionMixin href "" "scrapling.engines._browsers._base.StealthySessionMixin"
click scrapling.engines._browsers._base.BaseSessionMixin href "" "scrapling.engines._browsers._base.BaseSessionMixin"
An async Stealthy Browser session manager with page pooling.
A Browser session manager with page pooling, it's using a persistent browser Context by default with a temporary user profile directory.
| PARAMETER | DESCRIPTION |
|---|---|
headless
|
Run the browser in headless/hidden (default), or headful/visible mode.
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
|
blocked_domains
|
A set of domain names to block requests to. Subdomains are also matched (e.g.,
|
useragent
|
Pass a useragent string to be used. Otherwise the fetcher will generate a real Useragent of the same browser and use it.
|
cookies
|
Set cookies for the next request.
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
|
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the
|
page_action
|
Added for automation. A function that takes the
|
page_setup
|
A function that takes the
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
|
init_script
|
An absolute path to a JavaScript file to be executed on page creation for all pages in this session.
|
locale
|
Specify user locale, for example,
|
timezone_id
|
Changes the timezone of the browser. Defaults to the system timezone.
|
wait_selector_state
|
The state to wait for the selector given with
|
solve_cloudflare
|
Solves all types of the Cloudflare's Turnstile/Interstitial challenges before returning the response to you.
|
real_chrome
|
If you have a Chrome browser installed on your device, enable this, and the Fetcher will launch an instance of your browser and use it.
|
hide_canvas
|
Add random noise to canvas operations to prevent fingerprinting.
|
block_webrtc
|
Forces WebRTC to respect proxy settings to prevent local IP address leak.
|
allow_webgl
|
Enabled by default. Disabling it disables WebGL and WebGL 2.0 support entirely. Disabling WebGL is not recommended as many WAFs now check if WebGL is enabled.
|
load_dom
|
Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
|
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
|
extra_headers
|
A dictionary of extra headers to add to the request. The referer set by
|
proxy
|
The proxy to be used with requests, it can be a string or a dictionary with the keys 'server', 'username', and 'password' only.
|
user_data_dir
|
Path to a User Data Directory, which stores browser session data like cookies and local storage. The default is to create a temporary directory.
|
extra_flags
|
A list of additional browser flags to pass to the browser on launch.
|
selector_config
|
The arguments that will be passed in the end while creating the final Selector's class.
|
additional_args
|
Additional arguments to be passed to Playwright's context as additional settings, and it takes higher priority than Scrapling's settings.
|
Source code in scrapling/engines/_browsers/_stealth.py
__slots__
class-attribute
instance-attribute
¶
__slots__ = (
"_config",
"_context_options",
"_browser_options",
"_user_data_dir",
"_headers_keys",
)
__validate_routine__
¶
Source code in scrapling/engines/_browsers/_base.py
__generate_options__
¶
Source code in scrapling/engines/_browsers/_base.py
__validate__
¶
Source code in scrapling/engines/_browsers/_base.py
close
async
¶
Close all resources
Source code in scrapling/engines/_browsers/_base.py
__aenter__
async
¶
__aexit__
async
¶
get_pool_stats
¶
Get statistics about the current page pool
start
async
¶
Create a browser for this instance and context.
Source code in scrapling/engines/_browsers/_stealth.py
fetch
async
¶
Opens up the browser and do your request based on your chosen options.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The Target url.
TYPE:
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
|
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the
|
page_action
|
Added for automation. A function that takes the
|
page_setup
|
A function that takes the
|
extra_headers
|
A dictionary of extra headers to add to the request. The referer set by
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
|
blocked_domains
|
A set of domain names to block requests to. Subdomains are also matched (e.g.,
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
|
wait_selector_state
|
The state to wait for the selector given with
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
|
load_dom
|
Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
|
solve_cloudflare
|
Solves all types of the Cloudflare's Turnstile/Interstitial challenges before returning the response to you.
|
selector_config
|
The arguments that will be passed in the end while creating the final Selector's class.
|
proxy
|
Static proxy to override rotator and session proxy. A new browser context will be created and used with it.
|
| RETURNS | DESCRIPTION |
|---|---|
Response
|
A |
Source code in scrapling/engines/_browsers/_stealth.py
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | |
Dynamic Sessions¶
scrapling.fetchers.DynamicSession
¶
Bases: SyncSession, DynamicSessionMixin
flowchart TD
scrapling.fetchers.DynamicSession[DynamicSession]
scrapling.engines._browsers._base.SyncSession[SyncSession]
scrapling.engines._browsers._base.DynamicSessionMixin[DynamicSessionMixin]
scrapling.engines._browsers._base.BaseSessionMixin[BaseSessionMixin]
scrapling.engines._browsers._base.SyncSession --> scrapling.fetchers.DynamicSession
scrapling.engines._browsers._base.DynamicSessionMixin --> scrapling.fetchers.DynamicSession
scrapling.engines._browsers._base.BaseSessionMixin --> scrapling.engines._browsers._base.DynamicSessionMixin
click scrapling.fetchers.DynamicSession href "" "scrapling.fetchers.DynamicSession"
click scrapling.engines._browsers._base.SyncSession href "" "scrapling.engines._browsers._base.SyncSession"
click scrapling.engines._browsers._base.DynamicSessionMixin href "" "scrapling.engines._browsers._base.DynamicSessionMixin"
click scrapling.engines._browsers._base.BaseSessionMixin href "" "scrapling.engines._browsers._base.BaseSessionMixin"
A Browser session manager with page pooling.
A Browser session manager with page pooling, it's using a persistent browser Context by default with a temporary user profile directory.
| PARAMETER | DESCRIPTION |
|---|---|
headless
|
Run the browser in headless/hidden (default), or headful/visible mode.
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
|
blocked_domains
|
A set of domain names to block requests to. Subdomains are also matched (e.g.,
|
useragent
|
Pass a useragent string to be used. Otherwise the fetcher will generate a real Useragent of the same browser and use it.
|
cookies
|
Set cookies for the next request.
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
|
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the
|
page_action
|
Added for automation. A function that takes the
|
page_setup
|
A function that takes the
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
|
init_script
|
An absolute path to a JavaScript file to be executed on page creation for all pages in this session.
|
locale
|
Specify user locale, for example,
|
timezone_id
|
Changes the timezone of the browser. Defaults to the system timezone.
|
wait_selector_state
|
The state to wait for the selector given with
|
real_chrome
|
If you have a Chrome browser installed on your device, enable this, and the Fetcher will launch an instance of your browser and use it.
|
load_dom
|
Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
|
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
|
extra_headers
|
A dictionary of extra headers to add to the request. The referer set by
|
proxy
|
The proxy to be used with requests, it can be a string or a dictionary with the keys 'server', 'username', and 'password' only.
|
user_data_dir
|
Path to a User Data Directory, which stores browser session data like cookies and local storage. The default is to create a temporary directory.
|
extra_flags
|
A list of additional browser flags to pass to the browser on launch.
|
selector_config
|
The arguments that will be passed in the end while creating the final Selector's class.
|
additional_args
|
Additional arguments to be passed to Playwright's context as additional settings, and it takes higher priority than Scrapling's settings.
|
Source code in scrapling/engines/_browsers/_controllers.py
__slots__
class-attribute
instance-attribute
¶
__slots__ = (
"_config",
"_context_options",
"_browser_options",
"_user_data_dir",
"_headers_keys",
"max_pages",
"page_pool",
"_max_wait_for_page",
"playwright",
"context",
)
__validate_routine__
¶
Source code in scrapling/engines/_browsers/_base.py
__generate_options__
¶
Source code in scrapling/engines/_browsers/_base.py
__validate__
¶
close
¶
Close all resources
Source code in scrapling/engines/_browsers/_base.py
__enter__
¶
__exit__
¶
get_pool_stats
¶
Get statistics about the current page pool
start
¶
Create a browser for this instance and context.
Source code in scrapling/engines/_browsers/_controllers.py
fetch
¶
Opens up the browser and do your request based on your chosen options.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The Target url.
TYPE:
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
|
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the
|
page_action
|
Added for automation. A function that takes the
|
page_setup
|
A function that takes the
|
extra_headers
|
A dictionary of extra headers to add to the request. The referer set by
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
|
blocked_domains
|
A set of domain names to block requests to. Subdomains are also matched (e.g.,
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
|
wait_selector_state
|
The state to wait for the selector given with
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
|
load_dom
|
Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
|
selector_config
|
The arguments that will be passed in the end while creating the final Selector's class.
|
proxy
|
Static proxy to override rotator and session proxy. A new browser context will be created and used with it.
|
| RETURNS | DESCRIPTION |
|---|---|
Response
|
A |
Source code in scrapling/engines/_browsers/_controllers.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
scrapling.fetchers.AsyncDynamicSession
¶
Bases: AsyncSession, DynamicSessionMixin
flowchart TD
scrapling.fetchers.AsyncDynamicSession[AsyncDynamicSession]
scrapling.engines._browsers._base.AsyncSession[AsyncSession]
scrapling.engines._browsers._base.DynamicSessionMixin[DynamicSessionMixin]
scrapling.engines._browsers._base.BaseSessionMixin[BaseSessionMixin]
scrapling.engines._browsers._base.AsyncSession --> scrapling.fetchers.AsyncDynamicSession
scrapling.engines._browsers._base.DynamicSessionMixin --> scrapling.fetchers.AsyncDynamicSession
scrapling.engines._browsers._base.BaseSessionMixin --> scrapling.engines._browsers._base.DynamicSessionMixin
click scrapling.fetchers.AsyncDynamicSession href "" "scrapling.fetchers.AsyncDynamicSession"
click scrapling.engines._browsers._base.AsyncSession href "" "scrapling.engines._browsers._base.AsyncSession"
click scrapling.engines._browsers._base.DynamicSessionMixin href "" "scrapling.engines._browsers._base.DynamicSessionMixin"
click scrapling.engines._browsers._base.BaseSessionMixin href "" "scrapling.engines._browsers._base.BaseSessionMixin"
An async Browser session manager with page pooling, it's using a persistent browser Context by default with a temporary user profile directory.
A Browser session manager with page pooling
| PARAMETER | DESCRIPTION |
|---|---|
headless
|
Run the browser in headless/hidden (default), or headful/visible mode.
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
|
blocked_domains
|
A set of domain names to block requests to. Subdomains are also matched (e.g.,
|
useragent
|
Pass a useragent string to be used. Otherwise the fetcher will generate a real Useragent of the same browser and use it.
|
cookies
|
Set cookies for the next request.
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
|
load_dom
|
Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
|
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the
|
page_action
|
Added for automation. A function that takes the
|
page_setup
|
A function that takes the
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
|
init_script
|
An absolute path to a JavaScript file to be executed on page creation for all pages in this session.
|
locale
|
Specify user locale, for example,
|
timezone_id
|
Changes the timezone of the browser. Defaults to the system timezone.
|
wait_selector_state
|
The state to wait for the selector given with
|
real_chrome
|
If you have a Chrome browser installed on your device, enable this, and the Fetcher will launch an instance of your browser and use it.
|
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
|
extra_headers
|
A dictionary of extra headers to add to the request. The referer set by
|
proxy
|
The proxy to be used with requests, it can be a string or a dictionary with the keys 'server', 'username', and 'password' only.
|
max_pages
|
The maximum number of tabs to be opened at the same time. It will be used in rotation through a PagePool.
|
user_data_dir
|
Path to a User Data Directory, which stores browser session data like cookies and local storage. The default is to create a temporary directory.
|
extra_flags
|
A list of additional browser flags to pass to the browser on launch.
|
selector_config
|
The arguments that will be passed in the end while creating the final Selector's class.
|
additional_args
|
Additional arguments to be passed to Playwright's context as additional settings, and it takes higher priority than Scrapling's settings.
|
Source code in scrapling/engines/_browsers/_controllers.py
__slots__
class-attribute
instance-attribute
¶
__slots__ = (
"_config",
"_context_options",
"_browser_options",
"_user_data_dir",
"_headers_keys",
)
__validate_routine__
¶
Source code in scrapling/engines/_browsers/_base.py
__generate_options__
¶
Source code in scrapling/engines/_browsers/_base.py
__validate__
¶
close
async
¶
Close all resources
Source code in scrapling/engines/_browsers/_base.py
__aenter__
async
¶
__aexit__
async
¶
get_pool_stats
¶
Get statistics about the current page pool
start
async
¶
Create a browser for this instance and context.
Source code in scrapling/engines/_browsers/_controllers.py
fetch
async
¶
Opens up the browser and do your request based on your chosen options.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The Target url.
TYPE:
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
|
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the
|
page_action
|
Added for automation. A function that takes the
|
page_setup
|
A function that takes the
|
extra_headers
|
A dictionary of extra headers to add to the request. The referer set by
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
|
blocked_domains
|
A set of domain names to block requests to. Subdomains are also matched (e.g.,
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
|
wait_selector_state
|
The state to wait for the selector given with
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
|
load_dom
|
Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
|
selector_config
|
The arguments that will be passed in the end while creating the final Selector's class.
|
proxy
|
Static proxy to override rotator and session proxy. A new browser context will be created and used with it.
|
| RETURNS | DESCRIPTION |
|---|---|
Response
|
A |
Source code in scrapling/engines/_browsers/_controllers.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |