MCP Server API Reference¶
The Scrapling MCP Server provides eleven 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="127.0.0.1", port=8000)
To set a custom Chromium-compatible browser executable for browser-based MCP tools, pass executable_path:
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
¶
Create a Scrapling MCP server.
| PARAMETER | DESCRIPTION |
|---|---|
executable_path
|
Optional global Chromium-compatible browser executable path for browser tools. If omitted, the SCRAPLING_EXECUTABLE_PATH environment variable is used when set.
TYPE:
|
auth_token
|
Optional shared token that clients must send as
TYPE:
|
Source code in scrapling/core/ai.py
open_session
async
¶
open_session(
session_type,
session_id=None,
headless=True,
real_chrome=False,
timezone_id=None,
locale=None,
useragent=None,
proxy=None,
cdp_url=None,
executable_path=None,
cookies=None,
hide_canvas=False,
block_webrtc=False,
allow_webgl=True,
additional_args=None,
)
Open a persistent browser session that can be reused across multiple session_fetch calls.
This avoids the overhead of launching a new browser for each request. Sessions hold the browser-level
configuration only; per-request options are passed to session_fetch on each call.
| 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:
|
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:
|
timezone_id
|
Changes the timezone of the browser. Defaults to the system timezone.
TYPE:
|
locale
|
Specify user locale, for example,
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:
|
proxy
|
The proxy used for every request in this session, as a string or a dictionary with the keys 'server', 'username', and 'password' only. |
cdp_url
|
Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
TYPE:
|
executable_path
|
Absolute path to a custom Chromium-compatible browser executable. Overrides the server-wide default for this session.
TYPE:
|
cookies
|
Set cookies for the session. It should be in a dictionary format that Playwright accepts.
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:
|
additional_args
|
(Stealthy only) Additional arguments to be passed to Playwright's context as additional settings.
TYPE:
|
Source code in scrapling/core/ai.py
open_request_session
async
¶
Open a persistent HTTP requests session (no browser) that can be reused across multiple
session_make_request calls, keeping cookies, connections, and the browser fingerprint between requests.
The session holds this configuration only; per-request options are passed to session_make_request on each call.
It shares close_session/list_sessions with the browser sessions and shows there as a 'static' session.
| PARAMETER | DESCRIPTION |
|---|---|
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:
|
impersonate
|
Browser version to impersonate its fingerprint on every request. It's using the latest chrome version by default.
TYPE:
|
proxy
|
The proxy URL used for every request in this session. Format: "http://username:password@localhost:8030".
TYPE:
|
Source code in scrapling/core/ai.py
close_session
async
¶
Close a persistent 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 sessions with their details, including the effective settings each one was created with.
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.
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. |
wait_selector
|
Optional CSS selector to wait for before capturing.
TYPE:
|
wait_selector_state
|
State to wait for the selector.
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. |
Source code in scrapling/core/ai.py
make_request
async
staticmethod
¶
make_request(
url,
method="GET",
impersonate="chrome",
extraction_type="markdown",
css_selector=None,
main_content_only=True,
params=None,
data=None,
json=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 an HTTP request to a URL with any method (GET, POST, PUT, DELETE) and return a structured output of the result. Only suitable for low-mid protection levels.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The URL to request.
TYPE:
|
method
|
The HTTP method to use: "GET" (default), "POST", "PUT", or "DELETE".
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: "markdown", "html", or "text".
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.
TYPE:
|
main_content_only
|
Whether to extract only the main content of the page. The main content here is the data inside the
TYPE:
|
params
|
Query string parameters for the request.
TYPE:
|
data
|
Form data for the request body. Used with "POST", "PUT", and "DELETE" only. |
json
|
A JSON-serializable object for the request body. Used with "POST", "PUT", and "DELETE" only.
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. Use -1 for unlimited.
TYPE:
|
retries
|
Number of retry attempts.
TYPE:
|
retry_delay
|
Number of seconds to wait between retry attempts.
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. 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
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 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 | |
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. Only suitable for low-mid protection levels.
| 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: "markdown", "html", or "text".
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. 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. Use -1 for unlimited.
TYPE:
|
retries
|
Number of retry attempts.
TYPE:
|
retry_delay
|
Number of seconds to wait between retry attempts.
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. 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
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,
executable_path=None,
timeout=30000,
disable_resources=False,
wait_selector=None,
cookies=None,
network_idle=False,
wait_selector_state="attached",
)
Use playwright to open a browser to fetch a URL and return a structured output of the result. Only suitable for low-mid protection levels.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The URL to request.
TYPE:
|
extraction_type
|
The type of content to extract from the page: "markdown", "html", or "text".
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.
TYPE:
|
main_content_only
|
Whether to extract only the main content of the page. 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. |
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:
|
executable_path
|
Absolute path to a custom Chromium-compatible browser executable. Overrides the server-wide default for this request.
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. |
Source code in scrapling/core/ai.py
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,
executable_path=None,
timeout=30000,
disable_resources=False,
wait_selector=None,
cookies=None,
network_idle=False,
wait_selector_state="attached",
)
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. Only suitable for low-mid protection levels.
| PARAMETER | DESCRIPTION |
|---|---|
urls
|
A list of the URLs to request. Batches bigger than 50 URLs are fetched through a pool of 50 concurrent pages.
TYPE:
|
extraction_type
|
The type of content to extract from the page: "markdown", "html", or "text".
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.
TYPE:
|
main_content_only
|
Whether to extract only the main content of the page. 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. |
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:
|
executable_path
|
Absolute path to a custom Chromium-compatible browser executable. Overrides the server-wide default for this request.
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. |
Source code in scrapling/core/ai.py
657 658 659 660 661 662 663 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 | |
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,
executable_path=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,
)
Use the stealthy fetcher to fetch a URL and return a structured output of the result. The only fetcher suitable for high-protection websites.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The URL to request.
TYPE:
|
extraction_type
|
The type of content to extract from the page: "markdown", "html", or "text".
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.
TYPE:
|
main_content_only
|
Whether to extract only the main content of the page. 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. |
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:
|
executable_path
|
Absolute path to a custom Chromium-compatible browser executable. Overrides the server-wide default for this request.
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:
|
Source code in scrapling/core/ai.py
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 760 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 | |
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,
executable_path=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,
)
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. The only fetcher suitable for high-protection websites.
| PARAMETER | DESCRIPTION |
|---|---|
urls
|
A list of the URLs to request. Batches bigger than 50 URLs are fetched through a pool of 50 concurrent pages.
TYPE:
|
extraction_type
|
The type of content to extract from the page: "markdown", "html", or "text".
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.
TYPE:
|
main_content_only
|
Whether to extract only the main content of the page. 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. |
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:
|
executable_path
|
Absolute path to a custom Chromium-compatible browser executable. Overrides the server-wide default for this request.
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:
|
Source code in scrapling/core/ai.py
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 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | |
session_fetch
async
¶
session_fetch(
url,
session_id,
extraction_type="markdown",
css_selector=None,
main_content_only=True,
wait=0,
timeout=30000,
google_search=True,
network_idle=False,
load_dom=True,
disable_resources=False,
wait_selector=None,
wait_selector_state="attached",
extra_headers=None,
blocked_domains=None,
solve_cloudflare=False,
)
Fetch a URL through a browser session previously opened with open_session and return a structured output of the result.
The session (dynamic or stealthy) holds the browser-level configuration; every option here applies to this request only, with the defaults shown.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The URL to request.
TYPE:
|
session_id
|
ID of an open browser session created with
TYPE:
|
extraction_type
|
The type of content to extract from the page: "markdown", "html", or "text".
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.
TYPE:
|
main_content_only
|
Whether to extract only the main content of the page. The main content here is the data inside the
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. |
google_search
|
Enabled by default, Scrapling will set a Google referer header.
TYPE:
|
network_idle
|
Wait for the page until there are no network connections for at least 500 ms.
TYPE:
|
load_dom
|
Enabled by default, wait for all JavaScript on the page to fully load and execute.
TYPE:
|
disable_resources
|
Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type
TYPE:
|
wait_selector
|
Wait for a specific CSS selector to be in a specific state.
TYPE:
|
wait_selector_state
|
The state to wait for the selector given with
TYPE:
|
extra_headers
|
A dictionary of extra headers to add to the request. The referer set by |
blocked_domains
|
A list of domain names to block requests to for this request. Subdomains are also matched.
TYPE:
|
solve_cloudflare
|
(Stealthy sessions only) Solves all types of the Cloudflare's Turnstile/Interstitial challenges before returning the response.
TYPE:
|
Source code in scrapling/core/ai.py
session_make_request
async
¶
session_make_request(
url,
session_id,
method="GET",
extraction_type="markdown",
css_selector=None,
main_content_only=True,
params=None,
data=None,
json=None,
headers=None,
cookies=None,
timeout=30,
follow_redirects="safe",
max_redirects=30,
retries=3,
retry_delay=1,
auth=None,
verify=True,
http3=False,
stealthy_headers=True,
)
Make an HTTP request with any method (GET, POST, PUT, DELETE) through a requests session previously opened
with open_request_session, keeping its cookies, connections, and browser fingerprint across calls. The session
holds the impersonation and proxy configuration; every option here applies to this request only, with the defaults shown.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The URL to request.
TYPE:
|
session_id
|
ID of an open requests session created with
TYPE:
|
method
|
The HTTP method to use: "GET" (default), "POST", "PUT", or "DELETE".
TYPE:
|
extraction_type
|
The type of content to extract from the page: "markdown", "html", or "text".
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.
TYPE:
|
main_content_only
|
Whether to extract only the main content of the page. The main content here is the data inside the
TYPE:
|
params
|
Query string parameters for the request.
TYPE:
|
data
|
Form data for the request body. Used with "POST", "PUT", and "DELETE" only. |
json
|
A JSON-serializable object for the request body. Used with "POST", "PUT", and "DELETE" only.
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. Use -1 for unlimited.
TYPE:
|
retries
|
Number of retry attempts.
TYPE:
|
retry_delay
|
Number of seconds to wait between retry attempts.
TYPE:
|
auth
|
HTTP basic auth in dictionary format with |
verify
|
Whether to verify HTTPS certificates.
TYPE:
|
http3
|
Whether to use HTTP3. 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
987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 | |
serve
¶
Serve the MCP server.
| PARAMETER | DESCRIPTION |
|---|---|
http
|
Serve over the streamable-http transport instead of stdio.
TYPE:
|
host
|
The host to bind to when
TYPE:
|
port
|
The port to bind to when
TYPE:
|
allowed_hosts
|
Host names to accept, which turns on DNS-rebinding protection.
TYPE:
|
allow_unauthenticated
|
Start the streamable-http transport without a token. The transport requires authentication by default, so this is the explicit opt-out.
TYPE:
|