🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev
Python aiai-scrapingautomationcrawlercrawlingcrawling-pythondatadata-extractionmcpmcp-serverplaywrightpythonscrapingselectorsstealthweb-scraperweb-scrapingweb-scraping-pythonwebscrapingxpath
docs: update docs to add file downloading examples
Karim shoair026161c8f8b6
diff --git a/docs/fetching/choosing.md b/docs/fetching/choosing.mdindex 37b9c8c..50ddf37 100644--- a/docs/fetching/choosing.md+++ b/docs/fetching/choosing.md@@ -71,8 +71,7 @@ The `Response` object is the same as the [Selector](../parsing/main_classes.md#s>>> page.headers # Response headers>>> page.request_headers # Request headers>>> page.history # Response history of redirections, if any->>> page.body # Raw HTML response body without any processing->>> page.raw_response # Raw response of the last request made by the browser, if any (Useful for downloading binary files and text/json files)+>>> page.body # Raw response body without any processing>>> page.encoding # Response encoding```All fetchers return the `Response` object.\ No newline at end of filediff --git a/docs/fetching/dynamic.md b/docs/fetching/dynamic.mdindex 421dcbe..066d12c 100644--- a/docs/fetching/dynamic.md+++ b/docs/fetching/dynamic.md@@ -131,6 +131,17 @@ page = DynamicFetcher.fetch()```+### Downloading Files++```python+page = DynamicFetcher.fetch('https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/poster.png')++with open(file='poster.png', mode='wb') as f:+ f.write(page.body)+```++The `body` attribute of the `Response` object is a `bytes` object containing the response body in case of Non-HTML responses.+### Browser AutomationThis is where your knowledge about [Playwright's Page API](https://playwright.dev/python/docs/api/class-page) comes into play. The function you pass here takes the page object from Playwright's API, performs the desired action, and then the fetcher continues.diff --git a/docs/fetching/static.md b/docs/fetching/static.mdindex efd5717..43a2d0e 100644--- a/docs/fetching/static.md+++ b/docs/fetching/static.md@@ -269,6 +269,16 @@ def scrape_products():return results```+### Downloading Files++```python+from scrapling.fetchers import Fetcher++page = Fetcher.get('https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/poster.png')+with open(file='poster.png', mode='wb') as f:+ f.write(page.body)+```+### Pagination Handling```pythondiff --git a/docs/fetching/stealthy.md b/docs/fetching/stealthy.mdindex 9e11993..d53e930 100644--- a/docs/fetching/stealthy.md+++ b/docs/fetching/stealthy.md@@ -152,6 +152,17 @@ page = StealthyFetcher.fetch()```+### Downloading Files++```python+page = StealthyFetcher.fetch('https://raw.githubusercontent.com/D4Vinci/Scrapling/main/images/poster.png')++with open(file='poster.png', mode='wb') as f:+ f.write(page.body)+```++The `body` attribute of the `Response` object is a `bytes` object containing the response body in case of Non-HTML responses.+### Browser AutomationThis is where your knowledge about [Playwright's Page API](https://playwright.dev/python/docs/api/class-page) comes into play. The function you pass here takes the page object from Playwright's API, performs the desired action, and then the fetcher continues.