-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mazen-r/main
Add screenshot_flags and format api params support
- Loading branch information
Showing
4 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
This example shows how to capture page screenshots with images and additional configuration in scrapfly | ||
*/ | ||
import { ScrapflyClient, ScrapeConfig } from 'scrapfly-sdk'; | ||
|
||
const key = 'YOUR SCRAPFLY KEY'; | ||
const client = new ScrapflyClient({ key }); | ||
const result = await client.scrape( | ||
new ScrapeConfig({ | ||
url: 'https://web-scraping.dev/products/', | ||
// scrape the page data as markdown format supproted by LLMs. | ||
// None=raw(unchanged), other supported formats are: json, text, clean_html | ||
format: "markdown" | ||
}), | ||
); | ||
console.log(result.result.content); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
This example shows how to capture page screenshots with images and additional configuration in scrapfly | ||
*/ | ||
import { ScrapflyClient, ScrapeConfig } from 'scrapfly-sdk'; | ||
|
||
const key = 'YOUR SCRAPFLY KEY'; | ||
const client = new ScrapflyClient({ key }); | ||
const result = await client.scrape( | ||
new ScrapeConfig({ | ||
url: 'https://web-scraping.dev/products/', | ||
// enable headless browsers for screenshots | ||
render_js: true, | ||
// optional: you can wait for page to load before capturing | ||
screenshots: { | ||
everything: 'fullpage', | ||
reviews: '#reviews', | ||
}, | ||
screenshot_flags: [ | ||
"load_images", // Enable image rendering with the request, adds extra usage for the bandwidth consumed | ||
"dark_mode", // Enable dark mode display | ||
"block_banners", // Block cookies banners and overlay that cover the screen | ||
"high_quality", // No compression on the output image | ||
"print_media_format" // Render the page in the print mode | ||
] | ||
}), | ||
); | ||
console.log(result.result.screenshots); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters