scrapling 0.5.1__tar.gz → 0.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {scrapling-0.5.1/scrapling.egg-info → scrapling-0.5.2}/PKG-INFO +43 -36
- {scrapling-0.5.1 → scrapling-0.5.2}/README.md +32 -25
- {scrapling-0.5.1 → scrapling-0.5.2}/pyproject.toml +11 -11
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/__init__.py +1 -1
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/cli.py +4 -23
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/_shell_signatures.py +0 -1
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/ai/server.py +1 -18
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/_browsers/_base.py +7 -3
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/_browsers/_types.py +2 -4
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/_browsers/_validators.py +0 -6
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/static.py +10 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/toolbelt/custom.py +15 -32
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/toolbelt/navigation.py +3 -1
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/parser.py +23 -8
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/links.py +1 -1
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/request.py +29 -23
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/templates/_utils.py +6 -2
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/throttle.py +5 -1
- {scrapling-0.5.1 → scrapling-0.5.2/scrapling.egg-info}/PKG-INFO +43 -36
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling.egg-info/SOURCES.txt +2 -1
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling.egg-info/requires.txt +10 -10
- {scrapling-0.5.1 → scrapling-0.5.2}/setup.cfg +1 -1
- scrapling-0.5.2/tests/test_url_scheme_validation.py +28 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/LICENSE +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/MANIFEST.in +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/__init__.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/_types.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/ai/__init__.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/ai/_browser_actions.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/ai/_network_formatting.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/ai/_snapshot_search.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/custom_types.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/mixins.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/shell.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/storage.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/translator.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/utils/__init__.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/utils/_shell.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/core/utils/_utils.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/__init__.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/_browsers/__init__.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/_browsers/_config_tools.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/_browsers/_network.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/_browsers/_page.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/_browsers/_remote.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/_browsers/_stealth.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/constants.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/toolbelt/__init__.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/toolbelt/ad_domains.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/toolbelt/convertor.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/toolbelt/fingerprints.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/engines/toolbelt/proxy_rotation.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/fetchers/__init__.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/fetchers/requests.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/fetchers/stealth_chrome.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/integrations/__init__.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/integrations/scrapy.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/py.typed +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/__init__.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/cache.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/checkpoint.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/engine.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/result.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/robotstxt.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/scheduler.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/session.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/spider.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/templates/__init__.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/templates/crawler.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/templates/feed.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/templates/shopify.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/templates/site_to_markdown.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling/spiders/templates/sitemap.py +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling.egg-info/dependency_links.txt +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling.egg-info/entry_points.txt +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling.egg-info/not-zip-safe +0 -0
- {scrapling-0.5.1 → scrapling-0.5.2}/scrapling.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scrapling
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.2
|
|
4
4
|
Summary: Scrapling is an undetectable, powerful, flexible, high-performance Python framework that makes Web Scraping easy and effortless as it should be!
|
|
5
5
|
Home-page: https://github.com/D4Vinci/Scrapling
|
|
6
6
|
Author: Karim Shoair
|
|
@@ -68,32 +68,32 @@ Classifier: Typing :: Typed
|
|
|
68
68
|
Requires-Python: >=3.10
|
|
69
69
|
Description-Content-Type: text/markdown
|
|
70
70
|
License-File: LICENSE
|
|
71
|
-
Requires-Dist: lxml>=6.
|
|
71
|
+
Requires-Dist: lxml>=6.2.0
|
|
72
72
|
Requires-Dist: cssselect>=1.5.0
|
|
73
73
|
Requires-Dist: orjson>=3.11.8
|
|
74
74
|
Requires-Dist: tld>=0.13.2
|
|
75
|
-
Requires-Dist: w3lib>=2.
|
|
75
|
+
Requires-Dist: w3lib>=2.5.0
|
|
76
76
|
Requires-Dist: typing_extensions
|
|
77
77
|
Provides-Extra: fetchers
|
|
78
78
|
Requires-Dist: click>=8.3.0; extra == "fetchers"
|
|
79
|
-
Requires-Dist: curl_cffi>=0.
|
|
80
|
-
Requires-Dist: playwright>=1.
|
|
81
|
-
Requires-Dist: patchright>=1.
|
|
79
|
+
Requires-Dist: curl_cffi>=0.17.0; extra == "fetchers"
|
|
80
|
+
Requires-Dist: playwright>=1.64.1; extra == "fetchers"
|
|
81
|
+
Requires-Dist: patchright>=1.64.4; extra == "fetchers"
|
|
82
82
|
Requires-Dist: browserforge>=1.2.4; extra == "fetchers"
|
|
83
|
-
Requires-Dist: apify-fingerprint-datapoints>=0.
|
|
84
|
-
Requires-Dist: msgspec>=0.
|
|
83
|
+
Requires-Dist: apify-fingerprint-datapoints>=0.16.0; extra == "fetchers"
|
|
84
|
+
Requires-Dist: msgspec>=0.23.0; extra == "fetchers"
|
|
85
85
|
Requires-Dist: anyio>=4.14.0; extra == "fetchers"
|
|
86
86
|
Requires-Dist: protego>=0.7.0; extra == "fetchers"
|
|
87
87
|
Provides-Extra: rag
|
|
88
|
-
Requires-Dist: markdownify>=1.2.
|
|
88
|
+
Requires-Dist: markdownify>=1.2.4; extra == "rag"
|
|
89
89
|
Requires-Dist: scrapling[fetchers]; extra == "rag"
|
|
90
90
|
Provides-Extra: ai
|
|
91
91
|
Requires-Dist: mcp>=2.0.0; extra == "ai"
|
|
92
|
-
Requires-Dist: markdownify>=1.2.
|
|
92
|
+
Requires-Dist: markdownify>=1.2.4; extra == "ai"
|
|
93
93
|
Requires-Dist: scrapling[fetchers]; extra == "ai"
|
|
94
94
|
Provides-Extra: shell
|
|
95
95
|
Requires-Dist: IPython>=8.37; extra == "shell"
|
|
96
|
-
Requires-Dist: markdownify>=1.2.
|
|
96
|
+
Requires-Dist: markdownify>=1.2.4; extra == "shell"
|
|
97
97
|
Requires-Dist: scrapling[fetchers]; extra == "shell"
|
|
98
98
|
Provides-Extra: all
|
|
99
99
|
Requires-Dist: scrapling[ai,shell]; extra == "all"
|
|
@@ -224,7 +224,17 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
|
|
|
224
224
|
</a>
|
|
225
225
|
</td>
|
|
226
226
|
<td>
|
|
227
|
-
<a href="https://go.nodemaven.com/scraplingoctober" target="_blank">NodeMaven</a> - The most efficient proxy provider for Web Scraping and Automation with the Highest Quality IP on the market.
|
|
227
|
+
<a href="https://go.nodemaven.com/scraplingoctober" target="_blank">NodeMaven</a> - The most efficient proxy provider for Web Scraping and Automation with the Highest Quality IP on the market. SCRAPLING2X - 2X traffic for Black Friday
|
|
228
|
+
</td>
|
|
229
|
+
</tr>
|
|
230
|
+
<tr>
|
|
231
|
+
<td width="200">
|
|
232
|
+
<a href="https://usestring.ai/?utm_source=github-sponsor&utm_campaign=scrapling" target="_blank" title="Web access for everyone">
|
|
233
|
+
<img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/string.png" width="240" height="100">
|
|
234
|
+
</a>
|
|
235
|
+
</td>
|
|
236
|
+
<td>
|
|
237
|
+
<a href="https://usestring.ai/?utm_source=github-sponsor&utm_campaign=scrapling" target="_blank">String</a>: web search and fetch for AI agents. 98.6% success on 100 bot-protected sites, first of 17 APIs in our own benchmark.
|
|
228
238
|
</td>
|
|
229
239
|
</tr>
|
|
230
240
|
<tr>
|
|
@@ -270,16 +280,6 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
|
|
|
270
280
|
Read a full review of <a href="https://substack.thewebscraping.club/p/scrapling-hands-on-guide?utm_source=github&utm_medium=repo&utm_campaign=scrapling" target="_blank">Scrapling on The Web Scraping Club</a> (Nov 2025), the #1 newsletter dedicated to Web Scraping.
|
|
271
281
|
</td>
|
|
272
282
|
</tr>
|
|
273
|
-
<tr>
|
|
274
|
-
<td width="200">
|
|
275
|
-
<a href="https://www.swiftproxy.net/?ref=D4Vinci" target="_blank" title="Scalable Solutions for Web Data Access">
|
|
276
|
-
<img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/SwiftProxy.png">
|
|
277
|
-
</a>
|
|
278
|
-
</td>
|
|
279
|
-
<td>
|
|
280
|
-
<a href="https://www.swiftproxy.net/?ref=D4Vinci" target="_blank">Swiftproxy</a> provides scalable residential proxies with 80M+ IPs across 195+ countries, delivering fast, reliable connections, automatic rotation, and strong anti-block performance. Free trial available.
|
|
281
|
-
</td>
|
|
282
|
-
</tr>
|
|
283
283
|
<tr>
|
|
284
284
|
<td width="200">
|
|
285
285
|
<a href="https://byteful.com/?utm_source=github&utm_medium=github-sponsor&utm_campaign=scrapling_github_sponsor" target="_blank" title="Ethically sourced residential proxy infrastructure powering web scraping and AI agents">
|
|
@@ -290,16 +290,6 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
|
|
|
290
290
|
<a href="https://byteful.com/?utm_source=github&utm_medium=github-sponsor&utm_campaign=scrapling_github_sponsor" target="_blank">Byteful</a> supplies ethical residential, mobile, ISP, and datacenter proxies, plus scraping and AI automation tools. Use code SCRAPLING10: 10% off residential proxies.
|
|
291
291
|
</td>
|
|
292
292
|
</tr>
|
|
293
|
-
<tr>
|
|
294
|
-
<td width="200">
|
|
295
|
-
<a href="https://proxylane.dev/scrapling?utm_source=scrapling&utm_medium=affiliate&utm_campaign=scrapling_platinum_202609&utm_content=github_readme" target="_blank" title="90% fewer CAPTCHAs on your Scrapling runs.">
|
|
296
|
-
<img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/proxylane.png">
|
|
297
|
-
</a>
|
|
298
|
-
</td>
|
|
299
|
-
<td>
|
|
300
|
-
<a href="https://proxylane.dev/scrapling?utm_source=scrapling&utm_medium=affiliate&utm_campaign=scrapling_platinum_202609&utm_content=github_readme" target="_blank">ProxyLane</a>: 90% fewer CAPTCHAs on your Scrapling runs. 28M real P2P residential devices, 98.7% clean IPs, 195 countries. City/ISP/ZIP targeting, sticky/rotating sessions, traffic never expires. Try 350 MB for $1.95. Code <strong>SCRAPEANDTAKE</strong>: <em>25% off</em>.
|
|
301
|
-
</td>
|
|
302
|
-
</tr>
|
|
303
293
|
<tr>
|
|
304
294
|
<td width="200">
|
|
305
295
|
<a href="https://www.lundproxy.com/unlimited-residential-bandwidth.html?utm_source=github&utm_medium=sponsorship&utm_campaign=scrapling&utm_content=banner" target="_blank" title="Unlimited residential traffic, sized only by bandwidth.">
|
|
@@ -353,15 +343,14 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
|
|
|
353
343
|
|
|
354
344
|
<a href="https://serpapi.com/?utm_source=scrapling" target="_blank" title="Scrape Google and other search engines with SerpApi"><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/SerpApi.png"></a>
|
|
355
345
|
<a href="https://visit.decodo.com/Dy6W0b" target="_blank" title="Try the Most Efficient Residential Proxies for Free"><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/decodo.png"></a>
|
|
356
|
-
<a href="https://proxyempire.io/?ref=scrapling&utm_source=github&utm_medium=paid_referral&utm_campaign=open_source_sponsorship&utm_content=scrapling" target="_blank" title="Collect The Data Your Project Needs with the Best Residential Proxies"><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/ProxyEmpire.png"></a>
|
|
357
346
|
<a href="https://www.webshare.io/?referral_code=48r2m2cd5uz1" target="_blank" title="The Most Reliable Proxy with Unparalleled Performance"><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/webshare.png"></a>
|
|
358
347
|
<a href="https://proxiware.com/?ref=scrapling" target="_blank" title="Collect Any Data. At Any Scale."><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/proxiware.png"></a>
|
|
359
|
-
<a href="
|
|
348
|
+
<a href="http://olostep.com/" target="_blank" title="Web Data Infrastructure for AI"><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/olostep.png"></a>
|
|
360
349
|
|
|
361
350
|
|
|
362
351
|
<!-- /sponsors -->
|
|
363
352
|
|
|
364
|
-
<i><sub>Do you want to show your ad here?
|
|
353
|
+
<i><sub>Do you want to show your ad here? Choose the [Gold tier](https://github.com/sponsors/D4Vinci/sponsorships?tier_id=591422).</sub></i>
|
|
365
354
|
|
|
366
355
|
---
|
|
367
356
|
|
|
@@ -389,7 +378,7 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
|
|
|
389
378
|
- **Proxy Rotation**: Built-in `ProxyRotator` with cyclic or custom rotation strategies across all session types, plus per-request proxy overrides.
|
|
390
379
|
- **Domain & Ad Blocking**: Block requests to specific domains (and their subdomains) or enable built-in ad blocking (~3,500 known ad/tracker domains) in browser-based fetchers.
|
|
391
380
|
- **DNS Leak Prevention**: Optional DNS-over-HTTPS support to route DNS queries through Cloudflare's DoH, preventing DNS leaks when using proxies.
|
|
392
|
-
- **Remote Browsers**: Instead of launching a browser locally, connect to one that's already running through CDP with `cdp_url`, whether it's on the same machine, another host, or a managed browser provider. You can also point any browser fetcher at your own Chromium build with `
|
|
381
|
+
- **Remote Browsers**: Instead of launching a browser locally, connect to one that's already running through CDP with `cdp_url`, whether it's on the same machine, another host, or a managed browser provider. You can also point any browser fetcher at your own Chromium build with the `SCRAPLING_EXECUTABLE_PATH` environment variable.
|
|
393
382
|
- **Background API Capture**: Enable `record_requests=True` on a browser session, then search its saved responses with `session.network.search(limit=None)`. Read API data and HTTP errors across page loads without sending requests again. History is bounded and saves text response bodies.
|
|
394
383
|
- **Async Support**: Complete async support across all fetchers and dedicated async session classes.
|
|
395
384
|
|
|
@@ -645,6 +634,24 @@ pip install scrapling
|
|
|
645
634
|
> [!IMPORTANT]
|
|
646
635
|
> This installation only includes the parser engine and its dependencies, without any fetchers or commandline dependencies. So importing anything from `scrapling.fetchers` or `scrapling.spiders`, like in the examples above, will raise `ModuleNotFoundError` with this installation alone. If you are going to use any of the fetchers or spiders, install the fetchers' dependencies first as shown below.
|
|
647
636
|
|
|
637
|
+
### Set up Scrapling with your AI agent
|
|
638
|
+
|
|
639
|
+
Paste this prompt into Claude Code, Codex, Hermes, Openclaw, or any agent with shell access:
|
|
640
|
+
|
|
641
|
+
```text
|
|
642
|
+
Install scrapling[ai] from https://pypi.org/project/scrapling/ in this project's
|
|
643
|
+
virtual environment. Run `scrapling install` for browser support.
|
|
644
|
+
|
|
645
|
+
Download the official skill ZIP and extract it into this agent's skills directory.
|
|
646
|
+
https://github.com/D4Vinci/Scrapling/raw/refs/heads/main/agent-skill/Scrapling-Skill.zip
|
|
647
|
+
|
|
648
|
+
Register the full path to this environment's scrapling-mcp in this agent's MCP
|
|
649
|
+
settings. Call Scrapling's list_sessions tool to verify the connection. Tell me
|
|
650
|
+
the result or if I need to restart the app.
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
The agent handles the installation of Scrapling, its Agent Skill, and its MCP server.
|
|
654
|
+
|
|
648
655
|
### Optional Dependencies
|
|
649
656
|
|
|
650
657
|
1. If you are going to use any of the extra features below, the fetchers, or their classes, you will need to install fetchers' dependencies and their browser dependencies as follows:
|
|
@@ -123,7 +123,17 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
|
|
|
123
123
|
</a>
|
|
124
124
|
</td>
|
|
125
125
|
<td>
|
|
126
|
-
<a href="https://go.nodemaven.com/scraplingoctober" target="_blank">NodeMaven</a> - The most efficient proxy provider for Web Scraping and Automation with the Highest Quality IP on the market.
|
|
126
|
+
<a href="https://go.nodemaven.com/scraplingoctober" target="_blank">NodeMaven</a> - The most efficient proxy provider for Web Scraping and Automation with the Highest Quality IP on the market. SCRAPLING2X - 2X traffic for Black Friday
|
|
127
|
+
</td>
|
|
128
|
+
</tr>
|
|
129
|
+
<tr>
|
|
130
|
+
<td width="200">
|
|
131
|
+
<a href="https://usestring.ai/?utm_source=github-sponsor&utm_campaign=scrapling" target="_blank" title="Web access for everyone">
|
|
132
|
+
<img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/string.png" width="240" height="100">
|
|
133
|
+
</a>
|
|
134
|
+
</td>
|
|
135
|
+
<td>
|
|
136
|
+
<a href="https://usestring.ai/?utm_source=github-sponsor&utm_campaign=scrapling" target="_blank">String</a>: web search and fetch for AI agents. 98.6% success on 100 bot-protected sites, first of 17 APIs in our own benchmark.
|
|
127
137
|
</td>
|
|
128
138
|
</tr>
|
|
129
139
|
<tr>
|
|
@@ -169,16 +179,6 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
|
|
|
169
179
|
Read a full review of <a href="https://substack.thewebscraping.club/p/scrapling-hands-on-guide?utm_source=github&utm_medium=repo&utm_campaign=scrapling" target="_blank">Scrapling on The Web Scraping Club</a> (Nov 2025), the #1 newsletter dedicated to Web Scraping.
|
|
170
180
|
</td>
|
|
171
181
|
</tr>
|
|
172
|
-
<tr>
|
|
173
|
-
<td width="200">
|
|
174
|
-
<a href="https://www.swiftproxy.net/?ref=D4Vinci" target="_blank" title="Scalable Solutions for Web Data Access">
|
|
175
|
-
<img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/SwiftProxy.png">
|
|
176
|
-
</a>
|
|
177
|
-
</td>
|
|
178
|
-
<td>
|
|
179
|
-
<a href="https://www.swiftproxy.net/?ref=D4Vinci" target="_blank">Swiftproxy</a> provides scalable residential proxies with 80M+ IPs across 195+ countries, delivering fast, reliable connections, automatic rotation, and strong anti-block performance. Free trial available.
|
|
180
|
-
</td>
|
|
181
|
-
</tr>
|
|
182
182
|
<tr>
|
|
183
183
|
<td width="200">
|
|
184
184
|
<a href="https://byteful.com/?utm_source=github&utm_medium=github-sponsor&utm_campaign=scrapling_github_sponsor" target="_blank" title="Ethically sourced residential proxy infrastructure powering web scraping and AI agents">
|
|
@@ -189,16 +189,6 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
|
|
|
189
189
|
<a href="https://byteful.com/?utm_source=github&utm_medium=github-sponsor&utm_campaign=scrapling_github_sponsor" target="_blank">Byteful</a> supplies ethical residential, mobile, ISP, and datacenter proxies, plus scraping and AI automation tools. Use code SCRAPLING10: 10% off residential proxies.
|
|
190
190
|
</td>
|
|
191
191
|
</tr>
|
|
192
|
-
<tr>
|
|
193
|
-
<td width="200">
|
|
194
|
-
<a href="https://proxylane.dev/scrapling?utm_source=scrapling&utm_medium=affiliate&utm_campaign=scrapling_platinum_202609&utm_content=github_readme" target="_blank" title="90% fewer CAPTCHAs on your Scrapling runs.">
|
|
195
|
-
<img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/proxylane.png">
|
|
196
|
-
</a>
|
|
197
|
-
</td>
|
|
198
|
-
<td>
|
|
199
|
-
<a href="https://proxylane.dev/scrapling?utm_source=scrapling&utm_medium=affiliate&utm_campaign=scrapling_platinum_202609&utm_content=github_readme" target="_blank">ProxyLane</a>: 90% fewer CAPTCHAs on your Scrapling runs. 28M real P2P residential devices, 98.7% clean IPs, 195 countries. City/ISP/ZIP targeting, sticky/rotating sessions, traffic never expires. Try 350 MB for $1.95. Code <strong>SCRAPEANDTAKE</strong>: <em>25% off</em>.
|
|
200
|
-
</td>
|
|
201
|
-
</tr>
|
|
202
192
|
<tr>
|
|
203
193
|
<td width="200">
|
|
204
194
|
<a href="https://www.lundproxy.com/unlimited-residential-bandwidth.html?utm_source=github&utm_medium=sponsorship&utm_campaign=scrapling&utm_content=banner" target="_blank" title="Unlimited residential traffic, sized only by bandwidth.">
|
|
@@ -252,15 +242,14 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
|
|
|
252
242
|
|
|
253
243
|
<a href="https://serpapi.com/?utm_source=scrapling" target="_blank" title="Scrape Google and other search engines with SerpApi"><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/SerpApi.png"></a>
|
|
254
244
|
<a href="https://visit.decodo.com/Dy6W0b" target="_blank" title="Try the Most Efficient Residential Proxies for Free"><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/decodo.png"></a>
|
|
255
|
-
<a href="https://proxyempire.io/?ref=scrapling&utm_source=github&utm_medium=paid_referral&utm_campaign=open_source_sponsorship&utm_content=scrapling" target="_blank" title="Collect The Data Your Project Needs with the Best Residential Proxies"><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/ProxyEmpire.png"></a>
|
|
256
245
|
<a href="https://www.webshare.io/?referral_code=48r2m2cd5uz1" target="_blank" title="The Most Reliable Proxy with Unparalleled Performance"><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/webshare.png"></a>
|
|
257
246
|
<a href="https://proxiware.com/?ref=scrapling" target="_blank" title="Collect Any Data. At Any Scale."><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/proxiware.png"></a>
|
|
258
|
-
<a href="
|
|
247
|
+
<a href="http://olostep.com/" target="_blank" title="Web Data Infrastructure for AI"><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/olostep.png"></a>
|
|
259
248
|
|
|
260
249
|
|
|
261
250
|
<!-- /sponsors -->
|
|
262
251
|
|
|
263
|
-
<i><sub>Do you want to show your ad here?
|
|
252
|
+
<i><sub>Do you want to show your ad here? Choose the [Gold tier](https://github.com/sponsors/D4Vinci/sponsorships?tier_id=591422).</sub></i>
|
|
264
253
|
|
|
265
254
|
---
|
|
266
255
|
|
|
@@ -288,7 +277,7 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
|
|
|
288
277
|
- **Proxy Rotation**: Built-in `ProxyRotator` with cyclic or custom rotation strategies across all session types, plus per-request proxy overrides.
|
|
289
278
|
- **Domain & Ad Blocking**: Block requests to specific domains (and their subdomains) or enable built-in ad blocking (~3,500 known ad/tracker domains) in browser-based fetchers.
|
|
290
279
|
- **DNS Leak Prevention**: Optional DNS-over-HTTPS support to route DNS queries through Cloudflare's DoH, preventing DNS leaks when using proxies.
|
|
291
|
-
- **Remote Browsers**: Instead of launching a browser locally, connect to one that's already running through CDP with `cdp_url`, whether it's on the same machine, another host, or a managed browser provider. You can also point any browser fetcher at your own Chromium build with `
|
|
280
|
+
- **Remote Browsers**: Instead of launching a browser locally, connect to one that's already running through CDP with `cdp_url`, whether it's on the same machine, another host, or a managed browser provider. You can also point any browser fetcher at your own Chromium build with the `SCRAPLING_EXECUTABLE_PATH` environment variable.
|
|
292
281
|
- **Background API Capture**: Enable `record_requests=True` on a browser session, then search its saved responses with `session.network.search(limit=None)`. Read API data and HTTP errors across page loads without sending requests again. History is bounded and saves text response bodies.
|
|
293
282
|
- **Async Support**: Complete async support across all fetchers and dedicated async session classes.
|
|
294
283
|
|
|
@@ -544,6 +533,24 @@ pip install scrapling
|
|
|
544
533
|
> [!IMPORTANT]
|
|
545
534
|
> This installation only includes the parser engine and its dependencies, without any fetchers or commandline dependencies. So importing anything from `scrapling.fetchers` or `scrapling.spiders`, like in the examples above, will raise `ModuleNotFoundError` with this installation alone. If you are going to use any of the fetchers or spiders, install the fetchers' dependencies first as shown below.
|
|
546
535
|
|
|
536
|
+
### Set up Scrapling with your AI agent
|
|
537
|
+
|
|
538
|
+
Paste this prompt into Claude Code, Codex, Hermes, Openclaw, or any agent with shell access:
|
|
539
|
+
|
|
540
|
+
```text
|
|
541
|
+
Install scrapling[ai] from https://pypi.org/project/scrapling/ in this project's
|
|
542
|
+
virtual environment. Run `scrapling install` for browser support.
|
|
543
|
+
|
|
544
|
+
Download the official skill ZIP and extract it into this agent's skills directory.
|
|
545
|
+
https://github.com/D4Vinci/Scrapling/raw/refs/heads/main/agent-skill/Scrapling-Skill.zip
|
|
546
|
+
|
|
547
|
+
Register the full path to this environment's scrapling-mcp in this agent's MCP
|
|
548
|
+
settings. Call Scrapling's list_sessions tool to verify the connection. Tell me
|
|
549
|
+
the result or if I need to restart the app.
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
The agent handles the installation of Scrapling, its Agent Skill, and its MCP server.
|
|
553
|
+
|
|
547
554
|
### Optional Dependencies
|
|
548
555
|
|
|
549
556
|
1. If you are going to use any of the extra features below, the fetchers, or their classes, you will need to install fetchers' dependencies and their browser dependencies as follows:
|
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "scrapling"
|
|
7
7
|
# Static version instead of a dynamic version so we can get better layer caching while building docker, check the docker file to understand
|
|
8
|
-
version = "0.5.
|
|
8
|
+
version = "0.5.2"
|
|
9
9
|
description = "Scrapling is an undetectable, powerful, flexible, high-performance Python framework that makes Web Scraping easy and effortless as it should be!"
|
|
10
10
|
readme = {file = "README.md", content-type = "text/markdown"}
|
|
11
11
|
license = {file = "LICENSE"}
|
|
@@ -61,38 +61,38 @@ classifiers = [
|
|
|
61
61
|
"Typing :: Typed",
|
|
62
62
|
]
|
|
63
63
|
dependencies = [
|
|
64
|
-
"lxml>=6.
|
|
64
|
+
"lxml>=6.2.0",
|
|
65
65
|
"cssselect>=1.5.0",
|
|
66
66
|
"orjson>=3.11.8",
|
|
67
67
|
"tld>=0.13.2",
|
|
68
|
-
"w3lib>=2.
|
|
68
|
+
"w3lib>=2.5.0",
|
|
69
69
|
"typing_extensions"
|
|
70
70
|
]
|
|
71
71
|
|
|
72
72
|
[project.optional-dependencies]
|
|
73
73
|
fetchers = [
|
|
74
74
|
"click>=8.3.0",
|
|
75
|
-
"curl_cffi>=0.
|
|
76
|
-
"playwright>=1.
|
|
77
|
-
"patchright>=1.
|
|
75
|
+
"curl_cffi>=0.17.0",
|
|
76
|
+
"playwright>=1.64.1",
|
|
77
|
+
"patchright>=1.64.4",
|
|
78
78
|
"browserforge>=1.2.4",
|
|
79
|
-
"apify-fingerprint-datapoints>=0.
|
|
80
|
-
"msgspec>=0.
|
|
79
|
+
"apify-fingerprint-datapoints>=0.16.0",
|
|
80
|
+
"msgspec>=0.23.0",
|
|
81
81
|
"anyio>=4.14.0",
|
|
82
82
|
"protego>=0.7.0",
|
|
83
83
|
]
|
|
84
84
|
rag = [
|
|
85
|
-
"markdownify>=1.2.
|
|
85
|
+
"markdownify>=1.2.4",
|
|
86
86
|
"scrapling[fetchers]",
|
|
87
87
|
]
|
|
88
88
|
ai = [
|
|
89
89
|
"mcp>=2.0.0",
|
|
90
|
-
"markdownify>=1.2.
|
|
90
|
+
"markdownify>=1.2.4",
|
|
91
91
|
"scrapling[fetchers]",
|
|
92
92
|
]
|
|
93
93
|
shell = [
|
|
94
94
|
"IPython>=8.37", # The last version that supports Python 3.10
|
|
95
|
-
"markdownify>=1.2.
|
|
95
|
+
"markdownify>=1.2.4",
|
|
96
96
|
"scrapling[fetchers]",
|
|
97
97
|
]
|
|
98
98
|
all = [
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from os import environ
|
|
2
1
|
from pathlib import Path
|
|
3
2
|
from subprocess import check_output
|
|
4
3
|
from sys import executable as python_executable
|
|
@@ -120,14 +119,14 @@ def __BuildRequest(headers: List[str], cookies: str, params: str, json: Optional
|
|
|
120
119
|
def install(force): # pragma: no cover
|
|
121
120
|
if force or not __PACKAGE_DIR__.joinpath(".scrapling_dependencies_installed").exists():
|
|
122
121
|
__Execute(
|
|
123
|
-
[python_executable, "-m", "
|
|
122
|
+
[python_executable, "-m", "patchright", "install", "chromium"],
|
|
124
123
|
"Installing browsers",
|
|
125
124
|
)
|
|
126
125
|
__Execute(
|
|
127
126
|
[
|
|
128
127
|
python_executable,
|
|
129
128
|
"-m",
|
|
130
|
-
"
|
|
129
|
+
"patchright",
|
|
131
130
|
"install-deps",
|
|
132
131
|
"chromium",
|
|
133
132
|
],
|
|
@@ -159,12 +158,6 @@ def install(force): # pragma: no cover
|
|
|
159
158
|
@option(
|
|
160
159
|
"--port", type=int, default=8000, help="The port to use if streamable-http transport is enabled (Default: 8000)"
|
|
161
160
|
)
|
|
162
|
-
@option(
|
|
163
|
-
"--executable-path",
|
|
164
|
-
type=str,
|
|
165
|
-
default=None,
|
|
166
|
-
help="Path to a custom Chromium-compatible browser executable for browser-based MCP tools",
|
|
167
|
-
)
|
|
168
161
|
@option(
|
|
169
162
|
"--auth-token",
|
|
170
163
|
type=str,
|
|
@@ -186,10 +179,10 @@ def install(force): # pragma: no cover
|
|
|
186
179
|
help="Serve the streamable-http transport without authentication (not recommended). Without it, `--http` "
|
|
187
180
|
"refuses to start unless a token is given",
|
|
188
181
|
)
|
|
189
|
-
def mcp(http, host, port,
|
|
182
|
+
def mcp(http, host, port, auth_token, allowed_host, no_auth):
|
|
190
183
|
from scrapling.core.ai import ScraplingMCPServer
|
|
191
184
|
|
|
192
|
-
server = ScraplingMCPServer(
|
|
185
|
+
server = ScraplingMCPServer(auth_token=auth_token)
|
|
193
186
|
try:
|
|
194
187
|
server.serve(http, host, port, allowed_hosts=allowed_host, allow_unauthenticated=no_auth)
|
|
195
188
|
except ValueError as e:
|
|
@@ -299,12 +292,6 @@ def _common_browser_options(f):
|
|
|
299
292
|
default=False,
|
|
300
293
|
help="Extract only main content and sanitize hidden elements for AI consumption (default: False)",
|
|
301
294
|
),
|
|
302
|
-
option(
|
|
303
|
-
"--executable-path",
|
|
304
|
-
type=str,
|
|
305
|
-
default=None,
|
|
306
|
-
help="Path to a custom Chromium-compatible browser executable. Falls back to the SCRAPLING_EXECUTABLE_PATH environment variable when not set.",
|
|
307
|
-
),
|
|
308
295
|
option(
|
|
309
296
|
"--extra-headers",
|
|
310
297
|
"-H",
|
|
@@ -558,7 +545,6 @@ def __build_browser_kwargs(
|
|
|
558
545
|
parsed_headers,
|
|
559
546
|
dns_over_https,
|
|
560
547
|
block_ads,
|
|
561
|
-
executable_path,
|
|
562
548
|
) -> Dict[str, Any]:
|
|
563
549
|
"""Build shared kwargs dict for browser-based commands."""
|
|
564
550
|
kwargs: Dict[str, Any] = {
|
|
@@ -580,9 +566,6 @@ def __build_browser_kwargs(
|
|
|
580
566
|
kwargs["proxy"] = proxy
|
|
581
567
|
if parsed_headers:
|
|
582
568
|
kwargs["extra_headers"] = parsed_headers
|
|
583
|
-
executable_path = executable_path or environ.get("SCRAPLING_EXECUTABLE_PATH") or None
|
|
584
|
-
if executable_path:
|
|
585
|
-
kwargs["executable_path"] = executable_path
|
|
586
569
|
return kwargs
|
|
587
570
|
|
|
588
571
|
|
|
@@ -626,7 +609,6 @@ def fetch(
|
|
|
626
609
|
allow_webgl,
|
|
627
610
|
hide_canvas,
|
|
628
611
|
ai_targeted,
|
|
629
|
-
executable_path,
|
|
630
612
|
dns_over_https,
|
|
631
613
|
block_ads,
|
|
632
614
|
):
|
|
@@ -646,7 +628,6 @@ def fetch(
|
|
|
646
628
|
parsed_headers,
|
|
647
629
|
dns_over_https,
|
|
648
630
|
block_ads,
|
|
649
|
-
executable_path,
|
|
650
631
|
)
|
|
651
632
|
kwargs.update(
|
|
652
633
|
{
|
|
@@ -233,23 +233,16 @@ async def _stop_screencast(page: Any) -> None:
|
|
|
233
233
|
|
|
234
234
|
|
|
235
235
|
class ScraplingMCPServer:
|
|
236
|
-
def __init__(self,
|
|
236
|
+
def __init__(self, *, auth_token: Optional[str] = None):
|
|
237
237
|
"""Create a Scrapling MCP server.
|
|
238
238
|
|
|
239
|
-
:param executable_path: Optional global Chromium-compatible browser executable path for browser tools.
|
|
240
|
-
If omitted, the SCRAPLING_EXECUTABLE_PATH environment variable is used when set.
|
|
241
239
|
:param auth_token: Optional shared token that clients must send as `Authorization: Bearer <token>`.
|
|
242
240
|
If omitted, the SCRAPLING_MCP_AUTH_TOKEN environment variable is used when set. It only applies
|
|
243
241
|
to the streamable-http transport.
|
|
244
242
|
"""
|
|
245
243
|
self._sessions: Dict[str, _SessionEntry] = {}
|
|
246
|
-
self._executable_path = executable_path or environ.get(MCP_EXECUTABLE_PATH_ENV) or None
|
|
247
244
|
self._auth_token = auth_token or environ.get(MCP_AUTH_TOKEN_ENV) or None
|
|
248
245
|
|
|
249
|
-
def _resolve_executable_path(self, executable_path: Optional[str]) -> Optional[str]:
|
|
250
|
-
"""Return a per-call executable path or the server-wide default."""
|
|
251
|
-
return executable_path or self._executable_path
|
|
252
|
-
|
|
253
246
|
def _get_session(self, session_id: str, expected_type: List[SessionType]) -> _SessionEntry:
|
|
254
247
|
"""Look up an active session by ID and validate its type against the allowed types."""
|
|
255
248
|
entry = self._sessions.get(session_id)
|
|
@@ -312,10 +305,6 @@ class ScraplingMCPServer:
|
|
|
312
305
|
description="With cdp_url, create and close a separate context. False reuses and preserves the default context, ignoring useragent, locale, timezone_id, proxy and additional_args."
|
|
313
306
|
),
|
|
314
307
|
] = True,
|
|
315
|
-
executable_path: Annotated[
|
|
316
|
-
Optional[str],
|
|
317
|
-
Field(description="Absolute Chromium-compatible executable path; overrides the server default."),
|
|
318
|
-
] = None,
|
|
319
308
|
cookies: Annotated[
|
|
320
309
|
Sequence[SetCookieParam] | None, Field(description="Initial cookies as Playwright cookie dictionaries.")
|
|
321
310
|
] = None,
|
|
@@ -344,7 +333,6 @@ class ScraplingMCPServer:
|
|
|
344
333
|
else AsyncStealthySession(
|
|
345
334
|
headless=headless,
|
|
346
335
|
real_chrome=real_chrome,
|
|
347
|
-
executable_path=self._resolve_executable_path(executable_path),
|
|
348
336
|
hide_canvas=hide_canvas,
|
|
349
337
|
block_webrtc=block_webrtc,
|
|
350
338
|
allow_webgl=allow_webgl,
|
|
@@ -828,10 +816,6 @@ class ScraplingMCPServer:
|
|
|
828
816
|
Field(description="User-Agent override; otherwise generated in headless mode, native in headful mode."),
|
|
829
817
|
] = None,
|
|
830
818
|
hide_canvas: Annotated[bool, Field(description="Add noise to canvas operations.")] = False,
|
|
831
|
-
executable_path: Annotated[
|
|
832
|
-
Optional[str],
|
|
833
|
-
Field(description="Absolute Chromium-compatible executable path; overrides the server default."),
|
|
834
|
-
] = None,
|
|
835
819
|
timeout: Annotated[
|
|
836
820
|
int | float, Field(description="Navigation and page-operation timeout in milliseconds.")
|
|
837
821
|
] = 30000,
|
|
@@ -884,7 +868,6 @@ class ScraplingMCPServer:
|
|
|
884
868
|
wait_selector=wait_selector,
|
|
885
869
|
google_search=google_search,
|
|
886
870
|
extra_headers=extra_headers,
|
|
887
|
-
executable_path=self._resolve_executable_path(executable_path),
|
|
888
871
|
additional_args=additional_args,
|
|
889
872
|
solve_cloudflare=solve_cloudflare,
|
|
890
873
|
disable_resources=disable_resources,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from os import getenv
|
|
1
2
|
from time import time
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
from asyncio import sleep as asyncio_sleep, Lock
|
|
@@ -19,7 +20,7 @@ from patchright.async_api import (
|
|
|
19
20
|
from scrapling.parser import Selector
|
|
20
21
|
from scrapling.engines._browsers._page import PageInfo, PagePool
|
|
21
22
|
from scrapling.engines._browsers._network import NetworkRecorder
|
|
22
|
-
from scrapling.engines._browsers._validators import validate, PlaywrightConfig, StealthConfig
|
|
23
|
+
from scrapling.engines._browsers._validators import validate, PlaywrightConfig, StealthConfig, _is_invalid_file_path
|
|
23
24
|
from scrapling.engines._browsers._config_tools import __default_chrome_useragent__, __default_useragent__
|
|
24
25
|
from scrapling.engines.toolbelt.navigation import (
|
|
25
26
|
construct_proxy_dict,
|
|
@@ -533,6 +534,7 @@ class BaseSessionMixin:
|
|
|
533
534
|
|
|
534
535
|
if config.additional_args:
|
|
535
536
|
self._context_options.update(config.additional_args)
|
|
537
|
+
self._context_options.pop("executable_path", None)
|
|
536
538
|
|
|
537
539
|
def __generate_options__(self, extra_flags: Tuple | None = None) -> None:
|
|
538
540
|
self.__generate_context_options__()
|
|
@@ -549,8 +551,10 @@ class BaseSessionMixin:
|
|
|
549
551
|
self._browser_options.update(
|
|
550
552
|
{"args": flags, "headless": config.headless, "channel": "chrome" if config.real_chrome else "chromium"}
|
|
551
553
|
)
|
|
552
|
-
if
|
|
553
|
-
|
|
554
|
+
if executable_path := getenv("SCRAPLING_EXECUTABLE_PATH"):
|
|
555
|
+
if error := _is_invalid_file_path(executable_path, "Browser executable"):
|
|
556
|
+
raise ValueError(error)
|
|
557
|
+
self._browser_options["executable_path"] = executable_path
|
|
554
558
|
self._user_data_dir = config.user_data_dir
|
|
555
559
|
|
|
556
560
|
def _build_context_with_proxy(self, proxy: Optional[ProxyType] = None) -> Dict[str, Any]:
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from io import BytesIO
|
|
2
|
-
|
|
3
1
|
from curl_cffi.requests import (
|
|
4
2
|
ProxySpec,
|
|
5
3
|
CookieTypes,
|
|
@@ -56,7 +54,8 @@ class GetRequestParams(RequestsSession, total=False):
|
|
|
56
54
|
|
|
57
55
|
# Types for POST/PUT/DELETE request method parameters
|
|
58
56
|
class DataRequestParams(GetRequestParams, total=False):
|
|
59
|
-
data: Optional[Dict[str, str] | List[Tuple] | str |
|
|
57
|
+
data: Optional[Dict[str, str] | List[Tuple] | str | bytes]
|
|
58
|
+
content: Optional[str | bytes | bytearray]
|
|
60
59
|
json: Optional[Dict | List]
|
|
61
60
|
|
|
62
61
|
|
|
@@ -93,7 +92,6 @@ class _BrowserSession(TypedDict, total=False):
|
|
|
93
92
|
retry_delay: int | float
|
|
94
93
|
record_requests: bool
|
|
95
94
|
max_recorded_requests: int
|
|
96
|
-
executable_path: Optional[str]
|
|
97
95
|
dns_over_https: bool
|
|
98
96
|
|
|
99
97
|
|
|
@@ -91,7 +91,6 @@ class PlaywrightConfig(Struct, kw_only=True, frozen=False, weakref=True):
|
|
|
91
91
|
retry_delay: Seconds = 1
|
|
92
92
|
record_requests: bool = False
|
|
93
93
|
max_recorded_requests: Annotated[int, Meta(ge=1)] = 1000
|
|
94
|
-
executable_path: Optional[str] = None
|
|
95
94
|
dns_over_https: bool = False
|
|
96
95
|
|
|
97
96
|
def __post_init__(self): # pragma: no cover
|
|
@@ -122,11 +121,6 @@ class PlaywrightConfig(Struct, kw_only=True, frozen=False, weakref=True):
|
|
|
122
121
|
if validation_msg:
|
|
123
122
|
raise ValueError(validation_msg)
|
|
124
123
|
|
|
125
|
-
if self.executable_path is not None:
|
|
126
|
-
validation_msg = _is_invalid_file_path(self.executable_path, "Browser executable")
|
|
127
|
-
if validation_msg:
|
|
128
|
-
raise ValueError(validation_msg)
|
|
129
|
-
|
|
130
124
|
if self.block_ads:
|
|
131
125
|
from scrapling.engines.toolbelt.ad_domains import AD_DOMAINS
|
|
132
126
|
|
|
@@ -34,6 +34,15 @@ from .toolbelt.fingerprints import generate_headers, __default_useragent__
|
|
|
34
34
|
_NO_SESSION: Any = object()
|
|
35
35
|
|
|
36
36
|
|
|
37
|
+
def _validate_request_body(kwargs: Dict[str, Any]) -> None:
|
|
38
|
+
if kwargs.get("files") is not None or kwargs.get("multipart") is not None:
|
|
39
|
+
raise TypeError("Use prepared bytes in 'content' with Content-Type instead of 'files' or 'multipart'.")
|
|
40
|
+
for name, types in (("data", (dict, list, tuple, str, bytes)), ("content", (str, bytes, bytearray))):
|
|
41
|
+
value = kwargs.get(name)
|
|
42
|
+
if value is not None and not isinstance(value, types):
|
|
43
|
+
raise TypeError(f"'{name}' does not support streams. Read or encode the body as bytes before sending.")
|
|
44
|
+
|
|
45
|
+
|
|
37
46
|
def _select_random_browser(impersonate: ImpersonateType) -> Optional[BrowserTypeLiteral]:
|
|
38
47
|
"""
|
|
39
48
|
Handle browser selection logic for the ` impersonate ` parameter.
|
|
@@ -102,6 +111,7 @@ class _ConfigurationLogic(ABC):
|
|
|
102
111
|
|
|
103
112
|
def _merge_request_args(self, **method_kwargs) -> Dict[str, Any]:
|
|
104
113
|
"""Merge request-specific arguments with default session arguments."""
|
|
114
|
+
_validate_request_body(method_kwargs)
|
|
105
115
|
url = method_kwargs.pop("url")
|
|
106
116
|
|
|
107
117
|
# Get parameters from kwargs or use defaults
|