scrapling 0.5__tar.gz → 0.5.1__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.
Files changed (76) hide show
  1. {scrapling-0.5/scrapling.egg-info → scrapling-0.5.1}/PKG-INFO +28 -7
  2. {scrapling-0.5 → scrapling-0.5.1}/README.md +25 -4
  3. {scrapling-0.5 → scrapling-0.5.1}/pyproject.toml +3 -3
  4. {scrapling-0.5 → scrapling-0.5.1}/scrapling/__init__.py +1 -1
  5. {scrapling-0.5 → scrapling-0.5.1}/scrapling/cli.py +1 -1
  6. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/_shell_signatures.py +0 -1
  7. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/ai/_browser_actions.py +16 -0
  8. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/ai/server.py +114 -35
  9. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/shell.py +8 -0
  10. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/utils/_shell.py +20 -9
  11. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/_browsers/_base.py +64 -86
  12. scrapling-0.5.1/scrapling/engines/_browsers/_remote.py +79 -0
  13. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/_browsers/_stealth.py +31 -41
  14. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/_browsers/_types.py +14 -4
  15. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/_browsers/_validators.py +20 -6
  16. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/toolbelt/navigation.py +4 -3
  17. {scrapling-0.5 → scrapling-0.5.1}/scrapling/fetchers/__init__.py +5 -0
  18. {scrapling-0.5 → scrapling-0.5.1}/scrapling/fetchers/stealth_chrome.py +0 -2
  19. {scrapling-0.5 → scrapling-0.5.1}/scrapling/parser.py +12 -3
  20. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/cache.py +2 -1
  21. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/links.py +7 -4
  22. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/robotstxt.py +10 -2
  23. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/spider.py +2 -1
  24. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/templates/_utils.py +10 -6
  25. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/templates/feed.py +3 -1
  26. {scrapling-0.5 → scrapling-0.5.1/scrapling.egg-info}/PKG-INFO +28 -7
  27. {scrapling-0.5 → scrapling-0.5.1}/scrapling.egg-info/SOURCES.txt +1 -0
  28. {scrapling-0.5 → scrapling-0.5.1}/scrapling.egg-info/requires.txt +2 -2
  29. {scrapling-0.5 → scrapling-0.5.1}/setup.cfg +1 -1
  30. {scrapling-0.5 → scrapling-0.5.1}/LICENSE +0 -0
  31. {scrapling-0.5 → scrapling-0.5.1}/MANIFEST.in +0 -0
  32. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/__init__.py +0 -0
  33. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/_types.py +0 -0
  34. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/ai/__init__.py +0 -0
  35. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/ai/_network_formatting.py +0 -0
  36. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/ai/_snapshot_search.py +0 -0
  37. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/custom_types.py +0 -0
  38. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/mixins.py +0 -0
  39. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/storage.py +0 -0
  40. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/translator.py +0 -0
  41. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/utils/__init__.py +0 -0
  42. {scrapling-0.5 → scrapling-0.5.1}/scrapling/core/utils/_utils.py +0 -0
  43. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/__init__.py +0 -0
  44. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/_browsers/__init__.py +0 -0
  45. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/_browsers/_config_tools.py +0 -0
  46. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/_browsers/_network.py +0 -0
  47. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/_browsers/_page.py +0 -0
  48. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/constants.py +0 -0
  49. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/static.py +0 -0
  50. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/toolbelt/__init__.py +0 -0
  51. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/toolbelt/ad_domains.py +0 -0
  52. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/toolbelt/convertor.py +0 -0
  53. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/toolbelt/custom.py +0 -0
  54. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/toolbelt/fingerprints.py +0 -0
  55. {scrapling-0.5 → scrapling-0.5.1}/scrapling/engines/toolbelt/proxy_rotation.py +0 -0
  56. {scrapling-0.5 → scrapling-0.5.1}/scrapling/fetchers/requests.py +0 -0
  57. {scrapling-0.5 → scrapling-0.5.1}/scrapling/integrations/__init__.py +0 -0
  58. {scrapling-0.5 → scrapling-0.5.1}/scrapling/integrations/scrapy.py +0 -0
  59. {scrapling-0.5 → scrapling-0.5.1}/scrapling/py.typed +0 -0
  60. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/__init__.py +0 -0
  61. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/checkpoint.py +0 -0
  62. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/engine.py +0 -0
  63. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/request.py +0 -0
  64. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/result.py +0 -0
  65. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/scheduler.py +0 -0
  66. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/session.py +0 -0
  67. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/templates/__init__.py +0 -0
  68. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/templates/crawler.py +0 -0
  69. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/templates/shopify.py +0 -0
  70. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/templates/site_to_markdown.py +0 -0
  71. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/templates/sitemap.py +0 -0
  72. {scrapling-0.5 → scrapling-0.5.1}/scrapling/spiders/throttle.py +0 -0
  73. {scrapling-0.5 → scrapling-0.5.1}/scrapling.egg-info/dependency_links.txt +0 -0
  74. {scrapling-0.5 → scrapling-0.5.1}/scrapling.egg-info/entry_points.txt +0 -0
  75. {scrapling-0.5 → scrapling-0.5.1}/scrapling.egg-info/not-zip-safe +0 -0
  76. {scrapling-0.5 → scrapling-0.5.1}/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.1
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
@@ -76,14 +76,14 @@ Requires-Dist: w3lib>=2.4.1
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.16.1; extra == "fetchers"
79
+ Requires-Dist: curl_cffi>=0.16.3; extra == "fetchers"
80
80
  Requires-Dist: playwright>=1.62.0; extra == "fetchers"
81
81
  Requires-Dist: patchright>=1.62.1; extra == "fetchers"
82
82
  Requires-Dist: browserforge>=1.2.4; extra == "fetchers"
83
83
  Requires-Dist: apify-fingerprint-datapoints>=0.15.0; extra == "fetchers"
84
84
  Requires-Dist: msgspec>=0.21.1; extra == "fetchers"
85
85
  Requires-Dist: anyio>=4.14.0; extra == "fetchers"
86
- Requires-Dist: protego>=0.6.2; extra == "fetchers"
86
+ Requires-Dist: protego>=0.7.0; extra == "fetchers"
87
87
  Provides-Extra: rag
88
88
  Requires-Dist: markdownify>=1.2.0; extra == "rag"
89
89
  Requires-Dist: scrapling[fetchers]; extra == "rag"
@@ -219,12 +219,12 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
219
219
  <table>
220
220
  <tr>
221
221
  <td width="200">
222
- <a href="https://go.nodemaven.com/scraplingseptember" target="_blank" title="Proxies with the Highest IP Scores">
222
+ <a href="https://go.nodemaven.com/scraplingoctober" target="_blank" title="Proxies with the Highest IP Scores">
223
223
  <img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/NodeMaven.jpg" width="240" height="100">
224
224
  </a>
225
225
  </td>
226
226
  <td>
227
- <a href="https://go.nodemaven.com/scraplingseptember" target="_blank">NodeMaven</a> - The most efficient proxy provider for Web Scraping and Automation with the Highest Quality IP on the market. Use code SCRAPLING35 for 35% discount.
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. Use code SCRAPLING35 for 35% discount.
228
228
  </td>
229
229
  </tr>
230
230
  <tr>
@@ -292,12 +292,12 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
292
292
  </tr>
293
293
  <tr>
294
294
  <td width="200">
295
- <a href="https://proxylane.dev/?utm_source=scrapling&utm_medium=partnership&utm_campaign=scrapling_platinum_202609&utm_content=github_readme" target="_blank" title="28M+ clean residential IPs for browser automation. No Blocks. No CAPTCHAs. Pay-as-you-Go.">
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
296
  <img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/proxylane.png">
297
297
  </a>
298
298
  </td>
299
299
  <td>
300
- <a href="https://proxylane.dev/?utm_source=scrapling&utm_medium=partnership&utm_campaign=scrapling_platinum_202609&utm_content=github_readme" target="_blank">ProxyLane</a>: Reduce blocks and CAPTCHAs by 90%. 28M Premium Residential IPs for Heavy Web Scraping. 195 countries. City/ISP/ZIP targeting. Sticky/rotating sessions. Non-expiring traffic from $2/GB. Code <strong>SCRAPEANDTAKE</strong>: <em>25% off</em>.
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
301
  </td>
302
302
  </tr>
303
303
  <tr>
@@ -310,6 +310,26 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
310
310
  <a href="https://www.lundproxy.com?utm_source=github&utm_medium=sponsorship&utm_campaign=scrapling&utm_content=text" target="_blank">LundProxy</a>: Stop paying per GB. Unlimited residential traffic, 100M+ IPs, 190+ countries. Pay by bandwidth. Request a free 50 Mbps residential proxies trial.
311
311
  </td>
312
312
  </tr>
313
+ <tr>
314
+ <td width="200">
315
+ <a href="https://resolvr.com/?ref=scrapling" target="_blank" title="Captcha and Browser challenges, solved on real devices loading the page.">
316
+ <img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/resolvr.jpg">
317
+ </a>
318
+ </td>
319
+ <td>
320
+ <a href="https://resolvr.com/?ref=scrapling" target="_blank">Resolvr</a>: Scraping at scale means CAPTCHAs at scale. Resolvr solves reCAPTCHA and Cloudflare challenges on real devices through one API. Free beta access is available now.
321
+ </td>
322
+ </tr>
323
+ <tr>
324
+ <td width="200">
325
+ <a href="https://nonecap.com/solutions/scrapling/?ref=scrapling" target="_blank" title="hCaptcha solver as an API.">
326
+ <img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/Nonecap.png">
327
+ </a>
328
+ </td>
329
+ <td>
330
+ hCaptcha in your Scrapling runs? <a href="https://nonecap.com/solutions/scrapling/?ref=scrapling" target="_blank">NoneCap</a> returns valid hCaptcha tokens, Enterprise sitekeys included, through one API. 1,300 free credits on signup.
331
+ </td>
332
+ </tr>
313
333
  <tr>
314
334
  <td width="200">
315
335
  <a href="https://dataimpulse.com/?utm_source=website&utm_medium=github_readme&utm_campaign=scrapling_platinum" target="_blank" title="Buy Pay-as-you-go proxies from $1/GB">
@@ -336,6 +356,7 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
336
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>
337
357
  <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>
338
358
  <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="https://singaporemobileproxy.com/?utm_source=scrapling&utm_medium=sponsor&utm_campaign=paid_test_q4" target="_blank" title="Dedicated 4G/5G mobile proxies on real Singapore SIMs"><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/SingaporeMobileProxy.png"></a>
339
360
 
340
361
 
341
362
  <!-- /sponsors -->
@@ -118,12 +118,12 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
118
118
  <table>
119
119
  <tr>
120
120
  <td width="200">
121
- <a href="https://go.nodemaven.com/scraplingseptember" target="_blank" title="Proxies with the Highest IP Scores">
121
+ <a href="https://go.nodemaven.com/scraplingoctober" target="_blank" title="Proxies with the Highest IP Scores">
122
122
  <img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/NodeMaven.jpg" width="240" height="100">
123
123
  </a>
124
124
  </td>
125
125
  <td>
126
- <a href="https://go.nodemaven.com/scraplingseptember" target="_blank">NodeMaven</a> - The most efficient proxy provider for Web Scraping and Automation with the Highest Quality IP on the market. Use code SCRAPLING35 for 35% discount.
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. Use code SCRAPLING35 for 35% discount.
127
127
  </td>
128
128
  </tr>
129
129
  <tr>
@@ -191,12 +191,12 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
191
191
  </tr>
192
192
  <tr>
193
193
  <td width="200">
194
- <a href="https://proxylane.dev/?utm_source=scrapling&utm_medium=partnership&utm_campaign=scrapling_platinum_202609&utm_content=github_readme" target="_blank" title="28M+ clean residential IPs for browser automation. No Blocks. No CAPTCHAs. Pay-as-you-Go.">
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
195
  <img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/proxylane.png">
196
196
  </a>
197
197
  </td>
198
198
  <td>
199
- <a href="https://proxylane.dev/?utm_source=scrapling&utm_medium=partnership&utm_campaign=scrapling_platinum_202609&utm_content=github_readme" target="_blank">ProxyLane</a>: Reduce blocks and CAPTCHAs by 90%. 28M Premium Residential IPs for Heavy Web Scraping. 195 countries. City/ISP/ZIP targeting. Sticky/rotating sessions. Non-expiring traffic from $2/GB. Code <strong>SCRAPEANDTAKE</strong>: <em>25% off</em>.
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
200
  </td>
201
201
  </tr>
202
202
  <tr>
@@ -209,6 +209,26 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
209
209
  <a href="https://www.lundproxy.com?utm_source=github&utm_medium=sponsorship&utm_campaign=scrapling&utm_content=text" target="_blank">LundProxy</a>: Stop paying per GB. Unlimited residential traffic, 100M+ IPs, 190+ countries. Pay by bandwidth. Request a free 50 Mbps residential proxies trial.
210
210
  </td>
211
211
  </tr>
212
+ <tr>
213
+ <td width="200">
214
+ <a href="https://resolvr.com/?ref=scrapling" target="_blank" title="Captcha and Browser challenges, solved on real devices loading the page.">
215
+ <img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/resolvr.jpg">
216
+ </a>
217
+ </td>
218
+ <td>
219
+ <a href="https://resolvr.com/?ref=scrapling" target="_blank">Resolvr</a>: Scraping at scale means CAPTCHAs at scale. Resolvr solves reCAPTCHA and Cloudflare challenges on real devices through one API. Free beta access is available now.
220
+ </td>
221
+ </tr>
222
+ <tr>
223
+ <td width="200">
224
+ <a href="https://nonecap.com/solutions/scrapling/?ref=scrapling" target="_blank" title="hCaptcha solver as an API.">
225
+ <img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/Nonecap.png">
226
+ </a>
227
+ </td>
228
+ <td>
229
+ hCaptcha in your Scrapling runs? <a href="https://nonecap.com/solutions/scrapling/?ref=scrapling" target="_blank">NoneCap</a> returns valid hCaptcha tokens, Enterprise sitekeys included, through one API. 1,300 free credits on signup.
230
+ </td>
231
+ </tr>
212
232
  <tr>
213
233
  <td width="200">
214
234
  <a href="https://dataimpulse.com/?utm_source=website&utm_medium=github_readme&utm_campaign=scrapling_platinum" target="_blank" title="Buy Pay-as-you-go proxies from $1/GB">
@@ -235,6 +255,7 @@ This prints `10` and saves the quotes and authors to `quotes.json`.
235
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>
236
256
  <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>
237
257
  <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="https://singaporemobileproxy.com/?utm_source=scrapling&utm_medium=sponsor&utm_campaign=paid_test_q4" target="_blank" title="Dedicated 4G/5G mobile proxies on real Singapore SIMs"><img src="https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/SingaporeMobileProxy.png"></a>
238
259
 
239
260
 
240
261
  <!-- /sponsors -->
@@ -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.1"
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"}
@@ -72,14 +72,14 @@ dependencies = [
72
72
  [project.optional-dependencies]
73
73
  fetchers = [
74
74
  "click>=8.3.0",
75
- "curl_cffi>=0.16.1",
75
+ "curl_cffi>=0.16.3",
76
76
  "playwright>=1.62.0",
77
77
  "patchright>=1.62.1",
78
78
  "browserforge>=1.2.4",
79
79
  "apify-fingerprint-datapoints>=0.15.0",
80
80
  "msgspec>=0.21.1",
81
81
  "anyio>=4.14.0",
82
- "protego>=0.6.2",
82
+ "protego>=0.7.0",
83
83
  ]
84
84
  rag = [
85
85
  "markdownify>=1.2.0",
@@ -1,5 +1,5 @@
1
1
  __author__ = "Karim Shoair (scrapling@proton.me)"
2
- __version__ = "0.5"
2
+ __version__ = "0.5.1"
3
3
  __copyright__ = "Copyright (c) 2024 Karim Shoair"
4
4
 
5
5
  from typing import Any, TYPE_CHECKING
@@ -56,7 +56,7 @@ def __Request_and_Save(
56
56
  output_path = Path.cwd() / output_file
57
57
 
58
58
  if ai_targeted:
59
- kwargs.setdefault("block_ads", True)
59
+ kwargs["block_ads"] = True
60
60
  response = fetcher_func(url, **kwargs)
61
61
  Convertor.write_content_to_file(response, str(output_path), css_selector, main_content_only=ai_targeted)
62
62
  log.info(f"Content successfully saved to '{output_path}'")
@@ -62,7 +62,6 @@ _FETCH_PARAMS = {
62
62
  "additional_args": Optional[Dict],
63
63
  "locale": Optional[str],
64
64
  "real_chrome": bool,
65
- "cdp_url": Optional[str],
66
65
  "useragent": Optional[str],
67
66
  "extra_flags": Optional[List[str]],
68
67
  "blocked_domains": Optional[Set[str]],
@@ -60,6 +60,16 @@ class _MouseClick(_MouseTarget):
60
60
  ]
61
61
 
62
62
 
63
+ class _MouseDown(TypedDict):
64
+ type: Literal["mouse_down"]
65
+ button: NotRequired[Annotated[MouseButton, Field(default="left")]]
66
+
67
+
68
+ class _MouseUp(TypedDict):
69
+ type: Literal["mouse_up"]
70
+ button: NotRequired[Annotated[MouseButton, Field(default="left")]]
71
+
72
+
63
73
  class _MouseWheel(TypedDict):
64
74
  type: Literal["wheel"]
65
75
  delta_x: NotRequired[
@@ -138,6 +148,8 @@ BrowserAction = Annotated[
138
148
  Union[
139
149
  _MouseMove,
140
150
  _MouseClick,
151
+ _MouseDown,
152
+ _MouseUp,
141
153
  _MouseWheel,
142
154
  _TextFormField,
143
155
  _CheckboxFormField,
@@ -213,6 +225,10 @@ async def _run_actions(page: Any, actions: List[BrowserAction], slowly: bool = F
213
225
  await page.keyboard.press(action["key"])
214
226
  elif action["type"] == "wheel":
215
227
  await page.mouse.wheel(action.get("delta_x", 0), action.get("delta_y", 0))
228
+ elif action["type"] == "mouse_down":
229
+ await page.mouse.down(button=action.get("button", "left"))
230
+ elif action["type"] == "mouse_up":
231
+ await page.mouse.up(button=action.get("button", "left"))
216
232
  else:
217
233
  target = action.get("target")
218
234
  timeout = action.get("timeout", 30000)
@@ -1,4 +1,5 @@
1
1
  import re
2
+ from asyncio import CancelledError, create_task, shield, sleep
2
3
  from uuid import uuid4
3
4
  from os import environ
4
5
  from json import dumps
@@ -38,7 +39,7 @@ from ._snapshot_search import _search_snapshot
38
39
  from scrapling.core.shell import Convertor, _CONTROL_CHARS_PATTERN
39
40
  from scrapling.engines.toolbelt.custom import Response as _ScraplingResponse
40
41
  from scrapling.engines.toolbelt.convertor import ResponseFactory
41
- from scrapling.fetchers import FetcherSession, AsyncStealthySession
42
+ from scrapling.fetchers import FetcherSession, AsyncRemoteSession, AsyncStealthySession
42
43
  from scrapling.engines._browsers._types import StealthFetchParams
43
44
  from scrapling.core._types import (
44
45
  Optional,
@@ -93,8 +94,8 @@ def _session_settings(session: Any) -> Dict[str, Any]:
93
94
  name: value for name, value in fields.items() if isinstance(value, (str, int, float, bool)) or value is None
94
95
  }
95
96
  config = session._config
96
- if config.cdp_url:
97
- return {}
97
+ if getattr(config, "cdp_url", None):
98
+ return {"new_context": config.new_context}
98
99
  return {
99
100
  f: value
100
101
  for f in config.__struct_fields__
@@ -217,6 +218,20 @@ def _mcp_tool(tool: Callable[..., Awaitable[Any]]) -> Callable[..., Awaitable[An
217
218
  return wrapped
218
219
 
219
220
 
221
+ async def _stop_screencast(page: Any) -> None:
222
+ with CancelScope(shield=True):
223
+ stopped = create_task(page.screencast.stop())
224
+ cancelled = None
225
+ while not stopped.done():
226
+ try:
227
+ await shield(stopped)
228
+ except CancelledError as error:
229
+ cancelled = error
230
+ stopped.result()
231
+ if cancelled:
232
+ raise cancelled
233
+
234
+
220
235
  class ScraplingMCPServer:
221
236
  def __init__(self, executable_path: Optional[str] = None, auth_token: Optional[str] = None):
222
237
  """Create a Scrapling MCP server.
@@ -288,9 +303,15 @@ class ScraplingMCPServer:
288
303
  cdp_url: Annotated[
289
304
  Optional[str],
290
305
  Field(
291
- description="Connect to an existing Chromium browser over CDP in a new context; launch settings do not apply."
306
+ description="Connect to an existing Chromium browser over CDP; browser launch settings do not apply."
292
307
  ),
293
308
  ] = None,
309
+ new_context: Annotated[
310
+ bool,
311
+ Field(
312
+ 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
+ ),
314
+ ] = True,
294
315
  executable_path: Annotated[
295
316
  Optional[str],
296
317
  Field(description="Absolute Chromium-compatible executable path; overrides the server default."),
@@ -305,31 +326,37 @@ class ScraplingMCPServer:
305
326
  Optional[Dict], Field(description="Browser context options that override Scrapling settings.")
306
327
  ] = None,
307
328
  ) -> SessionCreatedModel:
308
- """Open a reusable stealthy browser session. Pass per-request options to `browser_fetch`."""
329
+ """Open a reusable local or remote browser session. Pass per-request options to `browser_fetch`."""
309
330
  session_id = self._new_session_id(session_id)
310
- session = AsyncStealthySession(
331
+ options: Dict[str, Any] = dict(
311
332
  proxy=proxy,
312
333
  locale=locale,
313
334
  cookies=cookies,
314
- cdp_url=cdp_url,
315
- headless=headless,
316
335
  block_ads=True,
317
336
  record_requests=True,
318
337
  useragent=useragent,
319
338
  timezone_id=timezone_id,
320
- real_chrome=real_chrome,
321
- executable_path=self._resolve_executable_path(executable_path),
322
- hide_canvas=hide_canvas,
323
- block_webrtc=block_webrtc,
324
- allow_webgl=allow_webgl,
325
339
  additional_args=additional_args,
326
340
  )
341
+ session = (
342
+ AsyncRemoteSession(cdp_url, new_context=new_context, **options)
343
+ if cdp_url is not None
344
+ else AsyncStealthySession(
345
+ headless=headless,
346
+ real_chrome=real_chrome,
347
+ executable_path=self._resolve_executable_path(executable_path),
348
+ hide_canvas=hide_canvas,
349
+ block_webrtc=block_webrtc,
350
+ allow_webgl=allow_webgl,
351
+ **options,
352
+ )
353
+ )
327
354
  await session.start()
328
355
  return self._register_session(session_id, session, "stealthy")
329
356
 
330
357
  async def browser_save_state(
331
358
  self,
332
- session_id: Annotated[str, Field(description="ID from `browser_open`; no page fetch required.")],
359
+ session_id: Annotated[str, Field(description="Browser session ID.")],
333
360
  path: Annotated[
334
361
  NonEmptyString,
335
362
  Field(
@@ -343,7 +370,7 @@ class ScraplingMCPServer:
343
370
 
344
371
  async def browser_load_state(
345
372
  self,
346
- session_id: Annotated[str, Field(description="ID from `browser_open`; no page fetch required.")],
373
+ session_id: Annotated[str, Field(description="Browser session ID.")],
347
374
  path: Annotated[
348
375
  NonEmptyString, Field(description="File on the MCP server host; relative to its working directory.")
349
376
  ],
@@ -416,7 +443,7 @@ class ScraplingMCPServer:
416
443
  ] = 0,
417
444
  limit: Annotated[int, Field(ge=1, le=200, description="Maximum requests to return.")] = 50,
418
445
  ) -> NetworkRequestsModel:
419
- """List completed requests across page changes, with IDs and pagination. Recording starts when the browser session opens."""
446
+ """List completed requests across page changes, with IDs and pagination. Recording starts when the browser session opens and closing does not wait for running captures."""
420
447
  network = self._get_session(session_id, ["stealthy"]).session.network
421
448
  records = network.search(
422
449
  url_pattern=url_pattern, include_static=include_static, after_id=after_id, limit=limit + 1
@@ -448,7 +475,7 @@ class ScraplingMCPServer:
448
475
 
449
476
  async def browser_extract(
450
477
  self,
451
- session_id: Annotated[str, Field(description="ID from `browser_open`; call `browser_fetch` first.")],
478
+ session_id: Annotated[str, Field(description="Browser session ID")],
452
479
  extraction_type: Annotated[
453
480
  SessionExtractionType, Field(description="Output format; defaults to an AI ARIA snapshot.")
454
481
  ] = "snapshot",
@@ -534,11 +561,12 @@ class ScraplingMCPServer:
534
561
 
535
562
  async def browser_actions(
536
563
  self,
537
- session_id: Annotated[str, Field(description="ID from `browser_open`; call `browser_fetch` first.")],
564
+ session_id: Annotated[str, Field(description="Browser session ID")],
538
565
  actions: Annotated[
539
566
  List[BrowserAction],
540
567
  Field(
541
- min_length=1, description="Ordered actions; fields need target; mouse needs target or viewport (x, y)."
568
+ min_length=1,
569
+ description="Ordered actions; fields need target; move/click need target or viewport (x, y); mouse_down/mouse_up act at the current pointer.",
542
570
  ),
543
571
  ],
544
572
  slowly: Annotated[
@@ -548,10 +576,13 @@ class ScraplingMCPServer:
548
576
  ),
549
577
  ] = False,
550
578
  ) -> str:
551
- """Run mouse, field, key, dialog, and wait actions in order; return plain text without a snapshot.
552
- Stop on the first error, identifying its action; partial effects remain. No retries.
579
+ """Chain all kinds of browser actions. Do actions without multiple calls or plan ahead to execute a sequence of actions.
580
+ Run mouse, field, key, dialog, and wait actions on the current page in order.
581
+ Load waits observe the current document; wait for a result element for delayed navigation.
582
+ Stops on the first error, identifying its action; partial effects remain. No retries.
553
583
  Element mouse targets auto-wait and scroll into view; coordinates and wheel do not wait for navigation or scrolling.
554
- Cancelled/timed-out clicks attempt button release. Load waits observe the current document, not future navigation."""
584
+ mouse_down holds across calls for observation and further moves; mouse_up releases, including after errors.
585
+ For drag and drop, move over the target twice before releasing. Cancelled/timed-out clicks attempt release."""
555
586
  _validate_actions(actions)
556
587
  with self._browser_page(session_id) as (_, page):
557
588
  await _run_actions(page, actions, slowly)
@@ -559,7 +590,7 @@ class ScraplingMCPServer:
559
590
 
560
591
  async def browser_evaluate(
561
592
  self,
562
- session_id: Annotated[str, Field(description="ID from `browser_open`; call `browser_fetch` first.")],
593
+ session_id: Annotated[str, Field(description="Browser session ID")],
563
594
  expression: Annotated[NonEmptyString, Field(description="JavaScript expression or function to invoke.")],
564
595
  arg: Annotated[
565
596
  Optional[Dict[str, Any]],
@@ -585,7 +616,7 @@ class ScraplingMCPServer:
585
616
 
586
617
  async def browser_screenshot(
587
618
  self,
588
- session_id: Annotated[str, Field(description="ID from `browser_open`; call `browser_fetch` first.")],
619
+ session_id: Annotated[str, Field(description="Browser session ID")],
589
620
  image_type: Annotated[ScreenshotType, Field(description="Image format.")] = "png",
590
621
  full_page: Annotated[
591
622
  bool, Field(description="Capture the full scrollable page; incompatible with selector/ref.")
@@ -635,6 +666,55 @@ class ScraplingMCPServer:
635
666
  data = await page.screenshot(full_page=full_page, **options)
636
667
  return [Image(data=data, format=image_type).to_image_content(), TextContent(type="text", text=page.url)]
637
668
 
669
+ async def browser_observe(
670
+ self,
671
+ session_id: Annotated[str, Field(description="Browser session ID")],
672
+ duration_ms: Annotated[int, Field(ge=100, le=5000, description="Observation window in milliseconds.")] = 1500,
673
+ max_frames: Annotated[int, Field(ge=2, le=20, description="Maximum number of sampled frames.")] = 12,
674
+ ) -> List[ImageContent | TextContent]:
675
+ """Inspect browser page motion through a short sequence of timestamped viewport images. The page keeps running during and after capture.
676
+ Use this tool when you get any challenge that require timed actions like games, appearing/disappearing CAPTCHAs, or interacting with any moving elements.
677
+ """
678
+ with self._browser_page(session_id) as (_, page):
679
+ frames: Dict[int, Dict[str, Any]] = {}
680
+ started = monotonic()
681
+
682
+ def capture(frame: Dict[str, Any]) -> None:
683
+ elapsed = (monotonic() - started) * 1000
684
+ if elapsed < duration_ms:
685
+ frames[int(elapsed * max_frames / duration_ms)] = frame
686
+
687
+ try:
688
+ await page.screencast.start(on_frame=capture, quality=60, size={"width": 800, "height": 800})
689
+ await sleep(max(0, duration_ms / 1000 - (monotonic() - started)))
690
+ except BaseException as error:
691
+ try:
692
+ await _stop_screencast(page)
693
+ except Exception as cleanup_error:
694
+ raise error from cleanup_error
695
+ raise
696
+ await _stop_screencast(page)
697
+ if not frames:
698
+ raise RuntimeError("No frames were captured. Try browser_screenshot or a longer observation window.")
699
+ return [
700
+ content
701
+ for frame in frames.values()
702
+ for content in (
703
+ TextContent(
704
+ type="text",
705
+ text=dumps(
706
+ {
707
+ "timestamp_ms": frame["timestamp"],
708
+ "viewport_width": frame["viewportWidth"],
709
+ "viewport_height": frame["viewportHeight"],
710
+ },
711
+ separators=(",", ":"),
712
+ ),
713
+ ),
714
+ Image(data=frame["data"], format="jpeg").to_image_content(),
715
+ )
716
+ ]
717
+
638
718
  @staticmethod
639
719
  async def make_request(
640
720
  url: Annotated[str, Field(description="URL to fetch.")],
@@ -748,12 +828,6 @@ class ScraplingMCPServer:
748
828
  Field(description="User-Agent override; otherwise generated in headless mode, native in headful mode."),
749
829
  ] = None,
750
830
  hide_canvas: Annotated[bool, Field(description="Add noise to canvas operations.")] = False,
751
- cdp_url: Annotated[
752
- Optional[str],
753
- Field(
754
- description="Connect to an existing Chromium browser over CDP in a new context; launch settings do not apply."
755
- ),
756
- ] = None,
757
831
  executable_path: Annotated[
758
832
  Optional[str],
759
833
  Field(description="Absolute Chromium-compatible executable path; overrides the server default."),
@@ -794,7 +868,6 @@ class ScraplingMCPServer:
794
868
  wait=wait,
795
869
  proxy=proxy,
796
870
  locale=locale,
797
- cdp_url=cdp_url,
798
871
  timeout=timeout,
799
872
  cookies=cookies,
800
873
  headless=headless,
@@ -824,7 +897,7 @@ class ScraplingMCPServer:
824
897
  async def browser_fetch(
825
898
  self,
826
899
  url: Annotated[str, Field(description="URL to fetch.")],
827
- session_id: Annotated[str, Field(description="ID from `browser_open`.")],
900
+ session_id: Annotated[str, Field(description="Browser session ID.")],
828
901
  extraction_type: Annotated[
829
902
  SessionExtractionType, Field(description="Content output format; snapshots include element bounding boxes.")
830
903
  ] = "markdown",
@@ -991,9 +1064,8 @@ class ScraplingMCPServer:
991
1064
  4. Fetch tools use `css_selector` to reduce output. HTML/Markdown/text return all matches; snapshots require one match or no selector for the whole page.
992
1065
  5. Session options persist from opening; fetch options apply per call, with schema defaults.
993
1066
  6. Each browser session uses one page; finish each call before starting the next in that session.
994
- 7. `browser_extract` reads the current page without navigation, as a snapshot by default. Snapshots include refs and boxes; `main_content_only` and `pierce_shadow` do not filter them.
995
- 8. `browser_actions` chains mouse, field, key, dialog and wait actions on the current page. Element actions use `target`: a Playwright selector or `aria-ref=<ref>` from the current snapshot. Move/click can instead use viewport (x, y) in CSS pixels. Wheel uses the current pointer without waiting for scrolling; coordinate clicks do not wait for navigation. Load waits observe the current document; wait for a result element for delayed navigation.
996
- 9. Network history saves completed requests and responses across page changes. Failed/unfinished requests are omitted; closing does not wait for running captures. Use `include_static=True` to list successful non-API traffic. Limits: 1000 requests and 20 MiB of saved response bodies; oldest records are removed first. Only response bodies with a text Content-Type are read and saved. Response bodies over 1 MiB are skipped; unavailable bodies are marked.""",
1067
+ 7. Network history capturing omits failed/unfinished requests. Limits: 1000 requests and 20 MiB of saved response bodies; oldest records are removed first. Response bodies over 1 MiB are skipped.
1068
+ 8. For challenges that have a slider with changing speed, don't release the mouse click without checking the page first to see if mouse adjustment needed before releasing. Keep repeating until you are certain.""",
997
1069
  }
998
1070
  if self._auth_token:
999
1071
  base_url = AnyHttpUrl(f"http://{host}:{port}")
@@ -1106,6 +1178,13 @@ class ScraplingMCPServer:
1106
1178
  structured_output=False,
1107
1179
  annotations=_FETCH_TOOL_ANNOTATIONS,
1108
1180
  )
1181
+ server.add_tool(
1182
+ _mcp_tool(self.browser_observe),
1183
+ title="Observe browser motion",
1184
+ description=self.browser_observe.__doc__,
1185
+ structured_output=False,
1186
+ annotations=_FETCH_TOOL_ANNOTATIONS,
1187
+ )
1109
1188
  return server
1110
1189
 
1111
1190
  def serve(
@@ -178,6 +178,7 @@ class CurlParser:
178
178
  # Connection/Security
179
179
  _parser.add_argument("-k", "--insecure", action="store_true")
180
180
  _parser.add_argument("--compressed", action="store_true") # Very common from browsers
181
+ _parser.add_argument("-L", "--location", action="store_true") # Redirects are followed anyway
181
182
 
182
183
  # Other flags often included but may not map directly to request args
183
184
  _parser.add_argument("-i", "--include", action="store_true")
@@ -442,6 +443,8 @@ class CustomShell:
442
443
  StealthyFetcher as __StealthyFetcher,
443
444
  StealthySession as __StealthySession,
444
445
  AsyncStealthySession as __AsyncStealthySession,
446
+ RemoteSession as __RemoteSession,
447
+ AsyncRemoteSession as __AsyncRemoteSession,
445
448
  )
446
449
 
447
450
  self.__InteractiveShellEmbed = __InteractiveShellEmbed
@@ -451,6 +454,8 @@ class CustomShell:
451
454
  self.__StealthyFetcher = __StealthyFetcher
452
455
  self.__StealthySession = __StealthySession
453
456
  self.__AsyncStealthySession = __AsyncStealthySession
457
+ self.__RemoteSession = __RemoteSession
458
+ self.__AsyncRemoteSession = __AsyncRemoteSession
454
459
  self.code = code
455
460
  self.page = None
456
461
  self.pages = Selectors([])
@@ -488,6 +493,7 @@ class CustomShell:
488
493
  -> Available Scrapling objects:
489
494
  - Fetcher/AsyncFetcher/FetcherSession
490
495
  - StealthyFetcher/StealthySession/AsyncStealthySession
496
+ - RemoteSession/AsyncRemoteSession
491
497
  - Selector
492
498
 
493
499
  -> Useful shortcuts:
@@ -564,6 +570,8 @@ Type 'exit' or press Ctrl+D to exit.
564
570
  "FetcherSession": self.__FetcherSession,
565
571
  "StealthySession": self.__StealthySession,
566
572
  "AsyncStealthySession": self.__AsyncStealthySession,
573
+ "RemoteSession": self.__RemoteSession,
574
+ "AsyncRemoteSession": self.__AsyncRemoteSession,
567
575
  "fetch": fetch,
568
576
  "StealthyFetcher": self.__StealthyFetcher,
569
577
  "Selector": Selector,
@@ -1,19 +1,30 @@
1
- from http import cookies as Cookie
2
-
3
-
4
1
  from scrapling.core._types import (
5
2
  List,
6
3
  Dict,
7
4
  Tuple,
5
+ Generator,
8
6
  )
9
7
 
8
+ # `Set-Cookie` attributes, skipped so a pasted `Set-Cookie` value still gives only the cookie itself.
9
+ # Bare flags (`Secure`, `HttpOnly`, `Partitioned`) have no `=` and are skipped anyway, so `partitioned` isn't listed:
10
+ # it's a valid cookie name, and listing it would drop a real `partitioned=...` request cookie.
11
+ _COOKIE_ATTRIBUTES = frozenset(
12
+ {"expires", "path", "comment", "domain", "max-age", "secure", "httponly", "version", "samesite"}
13
+ )
14
+
15
+
16
+ def _CookieParser(cookie_string: str) -> Generator[Tuple[str, str], None, None]:
17
+ """Split a cookie string like `a=1; b=2` into (name, value) pairs, keeping each value as it was sent.
10
18
 
11
- def _CookieParser(cookie_string):
12
- # Errors will be handled on call so the log can be specified
13
- cookie_parser = Cookie.SimpleCookie()
14
- cookie_parser.load(cookie_string)
15
- for key, morsel in cookie_parser.items():
16
- yield key, morsel.value
19
+ `http.cookies.SimpleCookie` isn't used here because it stops at the first value it considers invalid (a space,
20
+ a double quote, etc.) and silently drops that cookie and every one after it, while browsers send such values.
21
+ """
22
+ for pair in cookie_string.split(";"):
23
+ name, separator, value = pair.partition("=")
24
+ name = name.strip()
25
+ if not separator or not name or name.lower() in _COOKIE_ATTRIBUTES:
26
+ continue
27
+ yield name, value.strip()
17
28
 
18
29
 
19
30
  def _ParseHeaders(header_lines: List[str], parse_cookies: bool = True) -> Tuple[Dict[str, str], Dict[str, str]]: