MCP Server API Reference¶
The Scrapling MCP Server provides nine powerful tools for web scraping through the Model Context Protocol (MCP). This server integrates Scrapling's capabilities directly into AI chatbots and agents, allowing conversational web scraping with advanced anti-bot bypass features.
You can start the MCP server by running:
Or import the server class directly:
from scrapling.core.ai import ScraplingMCPServer
server = ScraplingMCPServer()
server.serve(http=False, host="0.0.0.0", port=8000)
Response Model¶
The standardized response structure that's returned by all MCP server tools:
scrapling.core.ai.ResponseModel
¶
Bases: BaseModel
flowchart TD
scrapling.core.ai.ResponseModel[ResponseModel]
click scrapling.core.ai.ResponseModel href "" "scrapling.core.ai.ResponseModel"
Request's response information structure.
Session Models¶
Model classes for session management:
scrapling.core.ai.SessionInfo
¶
Bases: BaseModel
flowchart TD
scrapling.core.ai.SessionInfo[SessionInfo]
click scrapling.core.ai.SessionInfo href "" "scrapling.core.ai.SessionInfo"
Information about an open browser session.
scrapling.core.ai.SessionCreatedModel
¶
Bases: SessionInfo
flowchart TD
scrapling.core.ai.SessionCreatedModel[SessionCreatedModel]
scrapling.core.ai.SessionInfo[SessionInfo]
scrapling.core.ai.SessionInfo --> scrapling.core.ai.SessionCreatedModel
click scrapling.core.ai.SessionCreatedModel href "" "scrapling.core.ai.SessionCreatedModel"
click scrapling.core.ai.SessionInfo href "" "scrapling.core.ai.SessionInfo"
Response returned when a new session is created.
scrapling.core.ai.SessionClosedModel
¶
Bases: BaseModel
flowchart TD
scrapling.core.ai.SessionClosedModel[SessionClosedModel]
click scrapling.core.ai.SessionClosedModel href "" "scrapling.core.ai.SessionClosedModel"
Response returned when a session is closed.
MCP Server Class¶
The main MCP server class that provides all web scraping tools:
scrapling.core.ai.ScraplingMCPServer
¶
Source code in scrapling/core/ai.py
open_session
async
¶
open_session(
session_type,
session_id=None,
headless=True,
google_search=True,
real_chrome=False,
wait=0,
proxy=None,
timezone_id=None,
locale=None,
extra_headers=None,
useragent=None,
cdp_url=None,
timeout=30000,
disable_resources=False,
wait_selector=None,
cookies=None,
network_idle=False,
wait_selector_state="attached",
max_pages=5,
hide_canvas=False,
block_webrtc=False,
allow_webgl=True,
solve_cloudflare=False,
additional_args=None,
)
Open a persistent browser session that can be reused across multiple fetch calls. This avoids the overhead of launching a new browser for each request. Use close_session to close the session when done, and list_sessions to see all active sessions.
| PARAMETER | DESCRIPTION |
|---|---|
session_type
|
The type of session to open. Use "dynamic" for standard Playwright browser, or "stealthy" for anti-bot bypass with fingerprint spoofing.
TYPE:
|
session_id
|
Optional custom session ID. If not provided, a random 12-character hex ID will be generated. Useful for naming sessions for easier management.
TYPE:
|
headless
|
Run the browser in headless/hidden (default), or headful/visible mode.
TYPE:
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
TYPE:
|
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.
TYPE:
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the Response object. |
proxy
|
The proxy to be used with requests, it can be a string or a dictionary with the keys 'server', 'username', and 'password' only. |
timezone_id
|
Changes the timezone of the browser. Defaults to the system timezone.
TYPE:
|
locale
|
Specify user locale, for example,
TYPE:
|
extra_headers
|
A dictionary of extra headers to add to the request. |
useragent
|
Pass a useragent string to be used. Otherwise the fetcher will generate a real Useragent of the same browser and use it.
TYPE:
|
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
TYPE:
|
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000. |
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
TYPE:
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
TYPE:
|
cookies
|
Set cookies for the session. It should be in a dictionary format that Playwright accepts.
TYPE:
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
TYPE:
|
wait_selector_state
|
The state to wait for the selector given with
TYPE:
|
max_pages
|
Maximum number of concurrent pages/tabs in the browser. Defaults to 5. Higher values allow more parallel fetches.
TYPE:
|
hide_canvas
|
(Stealthy only) Add random noise to canvas operations to prevent fingerprinting.
TYPE:
|
block_webrtc
|
(Stealthy only) Forces WebRTC to respect proxy settings to prevent local IP address leak.
TYPE:
|
allow_webgl
|
(Stealthy only) Enabled by default. Disabling WebGL is not recommended as many WAFs now check if WebGL is enabled.
TYPE:
|
solve_cloudflare
|
(Stealthy only) Solves all types of the Cloudflare's Turnstile/Interstitial challenges.
TYPE:
|
additional_args
|
(Stealthy only) Additional arguments to be passed to Playwright's context as additional settings.
TYPE:
|
Source code in scrapling/core/ai.py
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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
close_session
async
¶
Close a persistent browser session and free its resources.
| PARAMETER | DESCRIPTION |
|---|---|
session_id
|
The unique identifier of the session to close. Use list_sessions to see active sessions.
TYPE:
|
Source code in scrapling/core/ai.py
list_sessions
async
¶
List all active browser sessions with their details.
Source code in scrapling/core/ai.py
screenshot
async
¶
screenshot(
url,
session_id,
image_type="png",
full_page=False,
quality=None,
wait=0,
wait_selector=None,
wait_selector_state="attached",
network_idle=False,
timeout=30000,
)
Capture a screenshot of a web page using an existing browser session and return it as an image.
A browser session must be opened first with open_session (either dynamic or stealthy); the session ID is then passed here.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The URL to navigate to and capture.
TYPE:
|
session_id
|
ID of an open browser session created with
TYPE:
|
image_type
|
Image format. Defaults to "png". Use "jpeg" for smaller file sizes.
TYPE:
|
full_page
|
When True, captures the full scrollable page instead of just the viewport. Defaults to False.
TYPE:
|
quality
|
Image quality (0-100) for JPEG only. Raises if passed with
TYPE:
|
wait
|
Time in milliseconds to wait after page load before capturing. Defaults to 0. |
wait_selector
|
Optional CSS selector to wait for before capturing.
TYPE:
|
wait_selector_state
|
State to wait for the selector. Defaults to "attached".
TYPE:
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
TYPE:
|
timeout
|
Timeout in milliseconds for page operations. Defaults to 30,000. |
Source code in scrapling/core/ai.py
get
async
staticmethod
¶
get(
url,
impersonate="chrome",
extraction_type="markdown",
css_selector=None,
main_content_only=True,
params=None,
headers=None,
cookies=None,
timeout=30,
follow_redirects="safe",
max_redirects=30,
retries=3,
retry_delay=1,
proxy=None,
proxy_auth=None,
auth=None,
verify=True,
http3=False,
stealthy_headers=True,
)
Make GET HTTP request to a URL and return a structured output of the result.
Note: This is only suitable for low-mid protection levels. For high-protection levels or websites that require JS loading, use the other tools directly.
Note: If the css_selector resolves to more than one element, all the elements will be returned.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The URL to request.
TYPE:
|
impersonate
|
Browser version to impersonate its fingerprint. It's using the latest chrome version by default.
TYPE:
|
extraction_type
|
The type of content to extract from the page. Defaults to "markdown". Options are: - Markdown will convert the page content to Markdown format. - HTML will return the raw HTML content of the page. - Text will return the text content of the page.
TYPE:
|
css_selector
|
CSS selector to extract the content from the page. If main_content_only is True, then it will be executed on the main content of the page. Defaults to None.
TYPE:
|
main_content_only
|
Whether to extract only the main content of the page. Defaults to True. The main content here is the data inside the
TYPE:
|
params
|
Query string parameters for the request.
TYPE:
|
headers
|
Headers to include in the request. |
cookies
|
Cookies to use in the request. |
timeout
|
Number of seconds to wait before timing out. |
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:
|
retries
|
Number of retry attempts. Defaults to 3.
TYPE:
|
retry_delay
|
Number of seconds to wait between retry attempts. Defaults to 1 second.
TYPE:
|
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 in dictionary format with |
auth
|
HTTP basic auth in dictionary format with |
verify
|
Whether to verify HTTPS certificates.
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:
|
Source code in scrapling/core/ai.py
bulk_get
async
staticmethod
¶
bulk_get(
urls,
impersonate="chrome",
extraction_type="markdown",
css_selector=None,
main_content_only=True,
params=None,
headers=None,
cookies=None,
timeout=30,
follow_redirects="safe",
max_redirects=30,
retries=3,
retry_delay=1,
proxy=None,
proxy_auth=None,
auth=None,
verify=True,
http3=False,
stealthy_headers=True,
)
Make GET HTTP request to a group of URLs and for each URL, return a structured output of the result.
Note: This is only suitable for low-mid protection levels. For high-protection levels or websites that require JS loading, use the other tools directly.
Note: If the css_selector resolves to more than one element, all the elements will be returned.
| PARAMETER | DESCRIPTION |
|---|---|
urls
|
A list of the URLs to request.
TYPE:
|
impersonate
|
Browser version to impersonate its fingerprint. It's using the latest chrome version by default.
TYPE:
|
extraction_type
|
The type of content to extract from the page. Defaults to "markdown". Options are: - Markdown will convert the page content to Markdown format. - HTML will return the raw HTML content of the page. - Text will return the text content of the page.
TYPE:
|
css_selector
|
CSS selector to extract the content from the page. If main_content_only is True, then it will be executed on the main content of the page. Defaults to None.
TYPE:
|
main_content_only
|
Whether to extract only the main content of the page. Defaults to True. The main content here is the data inside the
TYPE:
|
params
|
Query string parameters for the request.
TYPE:
|
headers
|
Headers to include in the request. |
cookies
|
Cookies to use in the request. |
timeout
|
Number of seconds to wait before timing out. |
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:
|
retries
|
Number of retry attempts. Defaults to 3.
TYPE:
|
retry_delay
|
Number of seconds to wait between retry attempts. Defaults to 1 second.
TYPE:
|
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 in dictionary format with |
auth
|
HTTP basic auth in dictionary format with |
verify
|
Whether to verify HTTPS certificates.
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:
|
Source code in scrapling/core/ai.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
fetch
async
¶
fetch(
url,
extraction_type="markdown",
css_selector=None,
main_content_only=True,
headless=True,
google_search=True,
real_chrome=False,
wait=0,
proxy=None,
timezone_id=None,
locale=None,
extra_headers=None,
useragent=None,
cdp_url=None,
timeout=30000,
disable_resources=False,
wait_selector=None,
cookies=None,
network_idle=False,
wait_selector_state="attached",
session_id=None,
)
Use playwright to open a browser to fetch a URL and return a structured output of the result.
Note: This is only suitable for low-mid protection levels.
Note: If the css_selector resolves to more than one element, all the elements will be returned.
Note: If a session_id is provided (from open_session), the browser session will be reused instead of creating a new one.
When using a session, browser-level params (headless, proxy, locale, etc.) are ignored since they were set at session creation time.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The URL to request.
TYPE:
|
extraction_type
|
The type of content to extract from the page. Defaults to "markdown". Options are: - Markdown will convert the page content to Markdown format. - HTML will return the raw HTML content of the page. - Text will return the text content of the page.
TYPE:
|
css_selector
|
CSS selector to extract the content from the page. If main_content_only is True, then it will be executed on the main content of the page. Defaults to None.
TYPE:
|
main_content_only
|
Whether to extract only the main content of the page. Defaults to True. The main content here is the data inside the
TYPE:
|
headless
|
Run the browser in headless/hidden (default), or headful/visible mode.
TYPE:
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
TYPE:
|
useragent
|
Pass a useragent string to be used. Otherwise the fetcher will generate a real Useragent of the same browser and use it.
TYPE:
|
cookies
|
Set cookies for the next request. It should be in a dictionary format that Playwright accepts.
TYPE:
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
TYPE:
|
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 |
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
TYPE:
|
timezone_id
|
Changes the timezone of the browser. Defaults to the system timezone.
TYPE:
|
locale
|
Specify user locale, for example,
TYPE:
|
wait_selector_state
|
The state to wait for the selector given with
TYPE:
|
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.
TYPE:
|
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
TYPE:
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
TYPE:
|
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. |
session_id
|
Optional session ID from open_session. If provided, reuses the existing browser session instead of creating a new one.
TYPE:
|
Source code in scrapling/core/ai.py
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 | |
bulk_fetch
async
¶
bulk_fetch(
urls,
extraction_type="markdown",
css_selector=None,
main_content_only=True,
headless=True,
google_search=True,
real_chrome=False,
wait=0,
proxy=None,
timezone_id=None,
locale=None,
extra_headers=None,
useragent=None,
cdp_url=None,
timeout=30000,
disable_resources=False,
wait_selector=None,
cookies=None,
network_idle=False,
wait_selector_state="attached",
session_id=None,
)
Use playwright to open a browser, then fetch a group of URLs at the same time, and for each page return a structured output of the result.
Note: This is only suitable for low-mid protection levels.
Note: If the css_selector resolves to more than one element, all the elements will be returned.
Note: If a session_id is provided (from open_session), the browser session will be reused instead of creating a new one.
When using a session, browser-level params (headless, proxy, locale, etc.) are ignored since they were set at session creation time.
| PARAMETER | DESCRIPTION |
|---|---|
urls
|
A list of the URLs to request.
TYPE:
|
extraction_type
|
The type of content to extract from the page. Defaults to "markdown". Options are: - Markdown will convert the page content to Markdown format. - HTML will return the raw HTML content of the page. - Text will return the text content of the page.
TYPE:
|
css_selector
|
CSS selector to extract the content from the page. If main_content_only is True, then it will be executed on the main content of the page. Defaults to None.
TYPE:
|
main_content_only
|
Whether to extract only the main content of the page. Defaults to True. The main content here is the data inside the
TYPE:
|
headless
|
Run the browser in headless/hidden (default), or headful/visible mode.
TYPE:
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
TYPE:
|
useragent
|
Pass a useragent string to be used. Otherwise the fetcher will generate a real Useragent of the same browser and use it.
TYPE:
|
cookies
|
Set cookies for the next request. It should be in a dictionary format that Playwright accepts.
TYPE:
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
TYPE:
|
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 |
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
TYPE:
|
timezone_id
|
Changes the timezone of the browser. Defaults to the system timezone.
TYPE:
|
locale
|
Specify user locale, for example,
TYPE:
|
wait_selector_state
|
The state to wait for the selector given with
TYPE:
|
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.
TYPE:
|
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
TYPE:
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
TYPE:
|
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. |
session_id
|
Optional session ID from open_session. If provided, reuses the existing browser session instead of creating a new one.
TYPE:
|
Source code in scrapling/core/ai.py
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 | |
stealthy_fetch
async
¶
stealthy_fetch(
url,
extraction_type="markdown",
css_selector=None,
main_content_only=True,
headless=True,
google_search=True,
real_chrome=False,
wait=0,
proxy=None,
timezone_id=None,
locale=None,
extra_headers=None,
useragent=None,
hide_canvas=False,
cdp_url=None,
timeout=30000,
disable_resources=False,
wait_selector=None,
cookies=None,
network_idle=False,
wait_selector_state="attached",
block_webrtc=False,
allow_webgl=True,
solve_cloudflare=False,
additional_args=None,
session_id=None,
)
Use the stealthy fetcher to fetch a URL and return a structured output of the result.
Note: This is the only suitable fetcher for high protection levels.
Note: If the css_selector resolves to more than one element, all the elements will be returned.
Note: If a session_id is provided (from open_session), the browser session will be reused instead of creating a new one.
When using a session, browser-level params (headless, proxy, locale, etc.) are ignored since they were set at session creation time.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The URL to request.
TYPE:
|
extraction_type
|
The type of content to extract from the page. Defaults to "markdown". Options are: - Markdown will convert the page content to Markdown format. - HTML will return the raw HTML content of the page. - Text will return the text content of the page.
TYPE:
|
css_selector
|
CSS selector to extract the content from the page. If main_content_only is True, then it will be executed on the main content of the page. Defaults to None.
TYPE:
|
main_content_only
|
Whether to extract only the main content of the page. Defaults to True. The main content here is the data inside the
TYPE:
|
headless
|
Run the browser in headless/hidden (default), or headful/visible mode.
TYPE:
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
TYPE:
|
useragent
|
Pass a useragent string to be used. Otherwise the fetcher will generate a real Useragent of the same browser and use it.
TYPE:
|
cookies
|
Set cookies for the next request.
TYPE:
|
solve_cloudflare
|
Solves all types of the Cloudflare's Turnstile/Interstitial challenges before returning the response to you.
TYPE:
|
allow_webgl
|
Enabled by default. Disabling WebGL is not recommended as many WAFs now check if WebGL is enabled.
TYPE:
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
TYPE:
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the |
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000 |
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
TYPE:
|
timezone_id
|
Changes the timezone of the browser. Defaults to the system timezone.
TYPE:
|
locale
|
Specify user locale, for example,
TYPE:
|
wait_selector_state
|
The state to wait for the selector given with
TYPE:
|
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.
TYPE:
|
hide_canvas
|
Add random noise to canvas operations to prevent fingerprinting.
TYPE:
|
block_webrtc
|
Forces WebRTC to respect proxy settings to prevent local IP address leak.
TYPE:
|
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
TYPE:
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
TYPE:
|
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. |
additional_args
|
Additional arguments to be passed to Playwright's context as additional settings, and it takes higher priority than Scrapling's settings.
TYPE:
|
session_id
|
Optional session ID from open_session. If provided, reuses the existing browser session instead of creating a new one.
TYPE:
|
Source code in scrapling/core/ai.py
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | |
bulk_stealthy_fetch
async
¶
bulk_stealthy_fetch(
urls,
extraction_type="markdown",
css_selector=None,
main_content_only=True,
headless=True,
google_search=True,
real_chrome=False,
wait=0,
proxy=None,
timezone_id=None,
locale=None,
extra_headers=None,
useragent=None,
hide_canvas=False,
cdp_url=None,
timeout=30000,
disable_resources=False,
wait_selector=None,
cookies=None,
network_idle=False,
wait_selector_state="attached",
block_webrtc=False,
allow_webgl=True,
solve_cloudflare=False,
additional_args=None,
session_id=None,
)
Use the stealthy fetcher to fetch a group of URLs at the same time, and for each page return a structured output of the result.
Note: This is the only suitable fetcher for high protection levels.
Note: If the css_selector resolves to more than one element, all the elements will be returned.
Note: If a session_id is provided (from open_session), the browser session will be reused instead of creating a new one.
When using a session, browser-level params (headless, proxy, locale, etc.) are ignored since they were set at session creation time.
| PARAMETER | DESCRIPTION |
|---|---|
urls
|
A list of the URLs to request.
TYPE:
|
extraction_type
|
The type of content to extract from the page. Defaults to "markdown". Options are: - Markdown will convert the page content to Markdown format. - HTML will return the raw HTML content of the page. - Text will return the text content of the page.
TYPE:
|
css_selector
|
CSS selector to extract the content from the page. If main_content_only is True, then it will be executed on the main content of the page. Defaults to None.
TYPE:
|
main_content_only
|
Whether to extract only the main content of the page. Defaults to True. The main content here is the data inside the
TYPE:
|
headless
|
Run the browser in headless/hidden (default), or headful/visible mode.
TYPE:
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
TYPE:
|
useragent
|
Pass a useragent string to be used. Otherwise the fetcher will generate a real Useragent of the same browser and use it.
TYPE:
|
cookies
|
Set cookies for the next request.
TYPE:
|
solve_cloudflare
|
Solves all types of the Cloudflare's Turnstile/Interstitial challenges before returning the response to you.
TYPE:
|
allow_webgl
|
Enabled by default. Disabling WebGL is not recommended as many WAFs now check if WebGL is enabled.
TYPE:
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
TYPE:
|
wait
|
The time (milliseconds) the fetcher will wait after everything finishes before closing the page and returning the |
timeout
|
The timeout in milliseconds that is used in all operations and waits through the page. The default is 30,000 |
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
TYPE:
|
timezone_id
|
Changes the timezone of the browser. Defaults to the system timezone.
TYPE:
|
locale
|
Specify user locale, for example,
TYPE:
|
wait_selector_state
|
The state to wait for the selector given with
TYPE:
|
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.
TYPE:
|
hide_canvas
|
Add random noise to canvas operations to prevent fingerprinting.
TYPE:
|
block_webrtc
|
Forces WebRTC to respect proxy settings to prevent local IP address leak.
TYPE:
|
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
TYPE:
|
google_search
|
Enabled by default, Scrapling will set a Google referer header.
TYPE:
|
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. |
additional_args
|
Additional arguments to be passed to Playwright's context as additional settings, and it takes higher priority than Scrapling's settings.
TYPE:
|
session_id
|
Optional session ID from open_session. If provided, reuses the existing browser session instead of creating a new one.
TYPE:
|
Source code in scrapling/core/ai.py
761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
serve
¶
Serve the MCP server.