Skip to content

Commit 6ad2ecb

Browse files
authored
v0.3.13
2 parents 2e5152f + b5fdb71 commit 6ad2ecb

66 files changed

Lines changed: 1245 additions & 1674 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests.yml

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
- name: Install all browsers dependencies
5959
run: |
6060
python3 -m pip install --upgrade pip
61-
python3 -m pip install playwright==1.56.0 patchright==1.56.0 camoufox>=0.4.11
61+
python3 -m pip install playwright==1.56.0 patchright==1.56.0
6262
6363
- name: Get Playwright version
6464
id: playwright-version
@@ -88,35 +88,7 @@ jobs:
8888
else
8989
echo "Skipping install - using cached Playwright browsers"
9090
fi
91-
python3 -m playwright install-deps chromium firefox
92-
93-
- name: Get Camoufox version
94-
id: camoufox-version
95-
run: |
96-
CAMOUFOX_VERSION=$(python3 -c "import importlib.metadata; print(importlib.metadata.version('camoufox'))")
97-
echo "version=$CAMOUFOX_VERSION" >> $GITHUB_OUTPUT
98-
echo "Camoufox version: $CAMOUFOX_VERSION"
99-
100-
- name: Retrieve Camoufox browser from cache if any
101-
id: camoufox-cache
102-
uses: actions/cache@v4
103-
with:
104-
path: |
105-
~/.cache/camoufox
106-
~/Library/Caches/camoufox
107-
key: ${{ runner.os }}-camoufox-${{ steps.camoufox-version.outputs.version }}-v1
108-
restore-keys: |
109-
${{ runner.os }}-camoufox-${{ steps.camoufox-version.outputs.version }}-
110-
${{ runner.os }}-camoufox-
111-
112-
- name: Install Camoufox browser
113-
run: |
114-
echo "Cache hit: ${{ steps.camoufox-cache.outputs.cache-hit }}"
115-
if [ "${{ steps.camoufox-cache.outputs.cache-hit }}" != "true" ]; then
116-
python3 -m camoufox fetch --browserforge
117-
else
118-
echo "Skipping fetch - using cached Camoufox browser"
119-
fi
91+
python3 -m playwright install-deps chromium
12092
12193
# Cache tox environments
12294
- name: Cache tox environments

.readthedocs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ version: 2
77
# Set the OS, Python version, and other tools you might need
88
build:
99
os: ubuntu-24.04
10+
apt_packages:
11+
- pngquant
1012
tools:
1113
python: "3.13"
1214

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Thank you for your interest in contributing to Scrapling!
44

55
Everybody is invited and welcome to contribute to Scrapling.
66

7-
Minor changes have a better chance of being included promptly. Adding unit tests for new features or test cases for bugs you've fixed helps us ensure that the Pull Request (PR) is acceptable.
7+
Minor changes are more likely to be included promptly. Adding unit tests for new features or test cases for bugs you've fixed helps us ensure that the Pull Request (PR) is acceptable.
88

99
There are many ways to contribute to Scrapling. Here are some of them:
1010

@@ -18,7 +18,7 @@ There are many ways to contribute to Scrapling. Here are some of them:
1818

1919
If you have decided to make a contribution to Scrapling, but you do not know what to contribute, here are some ways to find pending work:
2020

21-
- Check out the [contribution](https://github.com/D4Vinci/Scrapling/contribute) GitHub page, which lists open issues tagged as good first issue. These issues provide a good starting point.
21+
- Check out the [contribution](https://github.com/D4Vinci/Scrapling/contribute) GitHub page, which lists open issues tagged as `good first issue`. These issues provide a good starting point.
2222
- There are also the [help wanted](https://github.com/D4Vinci/Scrapling/issues?q=is%3Aissue%20label%3A%22help%20wanted%22%20state%3Aopen) issues, but know that some may require familiarity with the Scrapling code base first. You can also target any other issue, provided it is not tagged as `invalid`, `wontfix`, or similar tags.
2323
- If you enjoy writing automated tests, you can work on increasing our test coverage. Currently, the test coverage is around 90–92%.
2424
- Join the [Discord community](https://discord.gg/EMgGbDceNQ) and ask questions in the `#help` channel.
@@ -38,7 +38,7 @@ Please follow these coding conventions as we do when writing code for Scrapling:
3838
| `refactor:` | Code refactoring |
3939
| `chore:` | Maintenance tasks |
4040

41-
Then include the details of the change in the body/description of the commit message.
41+
Then include the details of the change in the commit message body/description.
4242

4343
Example:
4444
```
@@ -99,7 +99,7 @@ pytest --cov=scrapling tests/
9999
To ensure that your PR gets accepted, please make sure that your PR is based on the latest changes from the dev branch and that it satisfies the following requirements:
100100

101101
- The PR should be made against the [**dev**](https://github.com/D4Vinci/Scrapling/tree/dev) branch of Scrapling. Any PR made against the main branch will be rejected.
102-
- The code should be passing all available tests. We are using tox with GitHub's CI to run the current tests on all supported Python versions with every commit.
102+
- The code should be passing all available tests. We use tox with GitHub's CI to run the current tests on all supported Python versions for every code-related commit.
103103
- The code should be passing all code quality checks we mentioned above. We are using GitHub's CI to enforce the code style checks performed by pre-commit. If you were using the pre-commit hooks we discussed above, you should not see any issues when committing your changes.
104104
- Make your changes, keep the code clean with an explanation of any part that might be vague, and remember to create a separate virtual environment for this project.
105105
- If you are adding a new feature, please add tests for it.

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ RUN --mount=type=cache,target=/root/.cache/uv \
2323
--mount=type=cache,target=/var/cache/apt \
2424
--mount=type=cache,target=/var/lib/apt \
2525
apt-get update && \
26-
uv run playwright install-deps chromium firefox && \
26+
uv run playwright install-deps chromium && \
2727
uv run playwright install chromium && \
28-
uv run camoufox fetch --browserforge && \
2928
uv sync --all-extras --compile-bytecode && \
3029
apt-get clean && \
3130
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

docs/README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ Built for the modern Web, Scrapling features **its own rapid parsing engine** an
9090

9191
### Advanced Websites Fetching with Session Support
9292
- **HTTP Requests**: Fast and stealthy HTTP requests with the `Fetcher` class. Can impersonate browsers' TLS fingerprint, headers, and use HTTP3.
93-
- **Dynamic Loading**: Fetch dynamic websites with full browser automation through the `DynamicFetcher` class supporting Playwright's Chromium, real Chrome, and custom stealth mode.
94-
- **Anti-bot Bypass**: Advanced stealth capabilities with `StealthyFetcher` using a modified version of Firefox and fingerprint spoofing. Can bypass all types of Cloudflare's Turnstile and Interstitial with automation easily.
93+
- **Dynamic Loading**: Fetch dynamic websites with full browser automation through the `DynamicFetcher` class supporting Playwright's Chromium and Google's Chrome.
94+
- **Anti-bot Bypass**: Advanced stealth capabilities with `StealthyFetcher` and fingerprint spoofing. Can easily bypass all types of Cloudflare's Turnstile/Interstitial with automation.
9595
- **Session Management**: Persistent session support with `FetcherSession`, `StealthySession`, and `DynamicSession` classes for cookie and state management across requests.
9696
- **Async Support**: Complete async support across all fetchers and dedicated async session classes.
9797

9898
### Adaptive Scraping & AI Integration
9999
- 🔄 **Smart Element Tracking**: Relocate elements after website changes using intelligent similarity algorithms.
100100
- 🎯 **Smart Flexible Selection**: CSS selectors, XPath selectors, filter-based search, text search, regex search, and more.
101101
- 🔍 **Find Similar Elements**: Automatically locate elements similar to found elements.
102-
- 🤖 **MCP Server to be used with AI**: Built-in MCP server for AI-assisted Web Scraping and data extraction. The MCP server features custom, powerful capabilities that utilize Scrapling to extract targeted content before passing it to the AI (Claude/Cursor/etc), thereby speeding up operations and reducing costs by minimizing token usage. ([demo video](https://www.youtube.com/watch?v=qyFk3ZNwOxE))
102+
- 🤖 **MCP Server to be used with AI**: Built-in MCP server for AI-assisted Web Scraping and data extraction. The MCP server features powerful, custom capabilities that leverage Scrapling to extract targeted content before passing it to the AI (Claude/Cursor/etc), thereby speeding up operations and reducing costs by minimizing token usage. ([demo video](https://www.youtube.com/watch?v=qyFk3ZNwOxE))
103103

104104
### High-Performance & battle-tested Architecture
105105
- 🚀 **Lightning Fast**: Optimized performance outperforming most Python scraping libraries.
@@ -153,7 +153,7 @@ data = page.css('.quote .text::text')
153153
```
154154

155155
> [!NOTE]
156-
> There's a wonderful guide to get you started quickly with Scraping [here](https://substack.thewebscraping.club/p/scrapling-hands-on-guide) written by The Web Scraping Club. In case you find it easier to get you started than the [documentation website](https://scrapling.readthedocs.io/en/latest/).
156+
> There's a wonderful guide to get you started quickly with Scrapling [here](https://substack.thewebscraping.club/p/scrapling-hands-on-guide) written by The Web Scraping Club. In case you find it easier to get you started than the [documentation website](https://scrapling.readthedocs.io/en/latest/).
157157
158158
### Advanced Parsing & Navigation
159159
```python
@@ -222,13 +222,12 @@ Scrapling v0.3 includes a powerful command-line interface:
222222

223223
[![asciicast](https://asciinema.org/a/736339.svg)](https://asciinema.org/a/736339)
224224

225+
Launch the interactive Web Scraping shell
225226
```bash
226-
# Launch interactive Web Scraping shell
227227
scrapling shell
228-
229-
# Extract pages to a file directly without programming (Extracts the content inside `body` tag by default)
230-
# If the output file ends with `.txt`, then the text content of the target will be extracted.
231-
# If ended with `.md`, it will be a markdown representation of the HTML content, and `.html` will be the HTML content right away.
228+
```
229+
Extract pages to a file directly without programming (Extracts the content inside the `body` tag by default). If the output file ends with `.txt`, then the text content of the target will be extracted. If it ends in `.md`, it will be a Markdown representation of the HTML content; if it ends in `.html`, it will be the HTML content itself.
230+
```bash
232231
scrapling extract get 'https://example.com' content.md
233232
scrapling extract get 'https://example.com' content.txt --css-selector '#fromSkipToProducts' --impersonate 'chrome' # All elements matching the CSS selector '#fromSkipToProducts'
234233
scrapling extract fetch 'https://example.com' content.md --css-selector '#fromSkipToProducts' --no-headless
@@ -240,7 +239,7 @@ scrapling extract stealthy-fetch 'https://nopecha.com/demo/cloudflare' captchas.
240239
241240
## Performance Benchmarks
242241

243-
Scrapling isn't just powerful—it's also blazing fast, and the updates since version 0.3 have delivered exceptional performance improvements across all operations.
242+
Scrapling isn't just powerful—it's also blazing fast, and the updates since version 0.3 have delivered exceptional performance improvements across all operations. The following benchmarks compare Scrapling's parser with other popular libraries.
244243

245244
### Text Extraction Speed Test (5000 nested elements)
246245

@@ -280,14 +279,14 @@ Starting with v0.3.2, this installation only includes the parser engine and its
280279

281280
### Optional Dependencies
282281

283-
1. If you are going to use any of the extra features below, the fetchers, or their classes, then you need to install fetchers' dependencies and then install their browser dependencies with
282+
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:
284283
```bash
285284
pip install "scrapling[fetchers]"
286285

287286
scrapling install
288287
```
289288

290-
This downloads all browsers with their system dependencies and fingerprint manipulation dependencies.
289+
This downloads all browsers, along with their system dependencies and fingerprint manipulation dependencies.
291290

292291
2. Extra features:
293292
- Install the MCP server feature:
@@ -313,7 +312,7 @@ Or download it from the GitHub registry:
313312
```bash
314313
docker pull ghcr.io/d4vinci/scrapling:latest
315314
```
316-
This image is automatically built and pushed through GitHub actions on the repository's main branch.
315+
This image is automatically built and pushed using GitHub Actions and the repository's main branch.
317316

318317
## Contributing
319318

docs/README_AR.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ Scrapling ليست مجرد مكتبة أخرى لاستخراج بيانات ا
8787

8888
### جلب متقدم للمواقع مع دعم الجلسات
8989
- **طلبات HTTP**: طلبات HTTP سريعة وخفية مع فئة `Fetcher`. يمكنها تقليد بصمة TLS للمتصفح والرؤوس واستخدام HTTP3.
90-
- **التحميل الديناميكي**: جلب المواقع الديناميكية مع أتمتة كاملة للمتصفح من خلال فئة `DynamicFetcher` التي تدعم Chromium من Playwright، وChrome الحقيقي، ووضع التخفي المخصص.
91-
- **تجاوز مكافحة الروبوتات**: قدرات تخفي متقدمة مع `StealthyFetcher` باستخدام نسخة معدلة من Firefox وانتحال البصمات. يمكنه تجاوز جميع أنواع Turnstile وInterstitial من Cloudflare بسهولة بالأتمتة.
90+
- **التحميل الديناميكي**: جلب المواقع الديناميكية مع أتمتة كاملة للمتصفح من خلال فئة `DynamicFetcher` التي تدعم Chromium من Playwright و Google Chrome.
91+
- **تجاوز مكافحة الروبوتات**: قدرات تخفي متقدمة مع `StealthyFetcher` وانتحال البصمات. يمكنه تجاوز جميع أنواع Turnstile/Interstitial من Cloudflare بسهولة بالأتمتة.
9292
- **إدارة الجلسات**: دعم الجلسات المستمرة مع فئات `FetcherSession` و`StealthySession` و`DynamicSession` لإدارة ملفات تعريف الارتباط والحالة عبر الطلبات.
9393
- **دعم Async**: دعم async كامل عبر جميع الجوالب وفئات الجلسات async المخصصة.
9494

9595
### الاستخراج التكيفي والتكامل مع الذكاء الاصطناعي
9696
- 🔄 **تتبع العناصر الذكي**: إعادة تحديد موقع العناصر بعد تغييرات الموقع باستخدام خوارزميات التشابه الذكية.
9797
- 🎯 **الاختيار المرن الذكي**: محددات CSS، محددات XPath، البحث القائم على الفلاتر، البحث النصي، البحث بالتعبيرات العادية والمزيد.
9898
- 🔍 **البحث عن عناصر مشابهة**: تحديد العناصر المشابهة للعناصر الموجودة تلقائياً.
99-
- 🤖 **خادم MCP للاستخدام مع الذكاء الاصطناعي**: خادم MCP مدمج لاستخراج بيانات الويب بمساعدة الذكاء الاصطناعي واستخراج البيانات. يتميز خادم MCP بقدرات مخصصة قوية تستخدم Scrapling لاستخراج المحتوى المستهدف قبل تمريره إلى الذكاء الاصطناعي (Claude/Cursor/إلخ)، وبالتالي تسريع العمليات وتقليل التكاليف عن طريق تقليل استخدام الرموز. ([فيديو توضيحي](https://www.youtube.com/watch?v=qyFk3ZNwOxE))
99+
- 🤖 **خادم MCP للاستخدام مع الذكاء الاصطناعي**: خادم MCP مدمج لاستخراج بيانات الويب بمساعدة الذكاء الاصطناعي واستخراج البيانات. يتميز خادم MCP بقدرات قوية مخصصة تستفيد من Scrapling لاستخراج المحتوى المستهدف قبل تمريره إلى الذكاء الاصطناعي (Claude/Cursor/إلخ)، وبالتالي تسريع العمليات وتقليل التكاليف عن طريق تقليل استخدام الرموز. ([فيديو توضيحي](https://www.youtube.com/watch?v=qyFk3ZNwOxE))
100100

101101
### بنية عالية الأداء ومختبرة في المعارك
102102
- 🚀 **سريع كالبرق**: أداء محسّن يتفوق على معظم مكتبات استخراج Python.
@@ -212,13 +212,12 @@ async with AsyncStealthySession(max_pages=2) as session:
212212

213213
[![asciicast](https://asciinema.org/a/736339.svg)](https://asciinema.org/a/736339)
214214

215+
تشغيل غلاف استخراج الويب التفاعلي
215216
```bash
216-
# تشغيل غلاف استخراج الويب التفاعلي
217217
scrapling shell
218-
219-
# استخراج الصفحات إلى ملف مباشرة دون برمجة (يستخرج المحتوى داخل وسم `body` افتراضياً)
220-
# إذا انتهى ملف الإخراج بـ `.txt`، فسيتم استخراج محتوى النص للهدف.
221-
# إذا انتهى بـ `.md`، فسيكون تمثيل markdown لمحتوى HTML، و`.html` سيكون محتوى HTML مباشرة.
218+
```
219+
استخراج الصفحات إلى ملف مباشرة دون برمجة (يستخرج المحتوى داخل وسم `body` افتراضياً). إذا انتهى ملف الإخراج بـ `.txt`، فسيتم استخراج محتوى النص للهدف. إذا انتهى بـ `.md`، فسيكون تمثيل Markdown لمحتوى HTML؛ إذا انتهى بـ `.html`، فسيكون محتوى HTML نفسه.
220+
```bash
222221
scrapling extract get 'https://example.com' content.md
223222
scrapling extract get 'https://example.com' content.txt --css-selector '#fromSkipToProducts' --impersonate 'chrome' # جميع العناصر المطابقة لمحدد CSS '#fromSkipToProducts'
224223
scrapling extract fetch 'https://example.com' content.md --css-selector '#fromSkipToProducts' --no-headless
@@ -230,7 +229,7 @@ scrapling extract stealthy-fetch 'https://nopecha.com/demo/cloudflare' captchas.
230229
231230
## معايير الأداء
232231

233-
Scrapling ليس قوياً فقط - إنه أيضاً سريع بشكل مذهل، والتحديثات منذ الإصدار 0.3 قدمت تحسينات أداء استثنائية عبر جميع العمليات.
232+
Scrapling ليس قوياً فقط - إنه أيضاً سريع بشكل مذهل، والتحديثات منذ الإصدار 0.3 قدمت تحسينات أداء استثنائية عبر جميع العمليات. تقارن المعايير التالية محلل Scrapling مع المكتبات الشائعة الأخرى.
234233

235234
### اختبار سرعة استخراج النص (5000 عنصر متداخل)
236235

@@ -270,14 +269,14 @@ pip install scrapling
270269

271270
### التبعيات الاختيارية
272271

273-
1. إذا كنت ستستخدم أياً من الميزات الإضافية أدناه، أو الجوالب، أو فئاتها، فأنت بحاجة إلى تثبيت تبعيات الجوالب ثم تثبيت تبعيات المتصفح الخاصة بها بـ
272+
1. إذا كنت ستستخدم أياً من الميزات الإضافية أدناه، أو الجوالب، أو فئاتها، فستحتاج إلى تثبيت تبعيات الجوالب وتبعيات المتصفح الخاصة بها على النحو التالي:
274273
```bash
275274
pip install "scrapling[fetchers]"
276275

277276
scrapling install
278277
```
279278

280-
يقوم هذا بتنزيل جميع المتصفحات مع تبعيات النظام وتبعيات معالجة البصمات الخاصة بها.
279+
يقوم هذا بتنزيل جميع المتصفحات، إلى جانب تبعيات النظام وتبعيات معالجة البصمات الخاصة بها.
281280

282281
2. ميزات إضافية:
283282
- تثبيت ميزة خادم MCP:
@@ -303,7 +302,7 @@ docker pull pyd4vinci/scrapling
303302
```bash
304303
docker pull ghcr.io/d4vinci/scrapling:latest
305304
```
306-
يتم بناء هذه الصورة ودفعها تلقائياً من خلال إجراءات GitHub على الفرع الرئيسي للمستودع.
305+
يتم بناء هذه الصورة ودفعها تلقائياً باستخدام GitHub Actions والفرع الرئيسي للمستودع.
307306

308307
## المساهمة
309308

0 commit comments

Comments
 (0)