-
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.
add axios-retry to retry client connection issues
update package versions, tests and docs
- Loading branch information
1 parent
3b113eb
commit d39eae8
Showing
10 changed files
with
1,274 additions
and
4,602 deletions.
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
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 |
---|---|---|
@@ -1,3 +1,22 @@ | ||
# Scrapfly Typescript SDK Examples | ||
|
||
This directory contains commonly used examples for the Scrapfly Typescript SDK. | ||
This directory contains commonly used examples for the Scrapfly Typescript SDK which is available in Typescript runtimes (bun, deno) as well as javascript ones like Nodejs. | ||
|
||
You can use `node` to run the `.js` examples: | ||
|
||
``` | ||
node examples/basic-get.js | ||
``` | ||
|
||
Or compile `.ts` examples to `.js`: | ||
|
||
``` | ||
tsc examples/basic-get.ts -o examples/basic-get.js | ||
node examples/basic-get.js | ||
``` | ||
|
||
Or run typescript directly through runtimes like `.ts`: | ||
|
||
``` | ||
bun examples/basic-get.ts | ||
``` |
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,13 @@ | ||
/* | ||
Most basic scrapfly request - GET a provided url | ||
*/ | ||
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://httpbin.dev/html', | ||
}), | ||
); | ||
console.log(result.result.content); // html 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
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,17 @@ | ||
/* | ||
* This example shows how to download binary data from scrapfly responses. | ||
*/ | ||
import { ScrapflyClient, ScrapeConfig } from 'scrapfly-sdk'; | ||
import fs from 'fs'; | ||
const key = 'YOUR SCRAPFLY KEY'; | ||
const client = new ScrapflyClient({ key }); | ||
const result = await client.scrape( | ||
new ScrapeConfig({ | ||
url: 'https://web-scraping.dev/product/1', | ||
render_js: true, | ||
js: 'return document.title', | ||
}), | ||
); | ||
// then stream content as base64 buffer: | ||
const data = Buffer.from(result.result.content, 'base64'); | ||
fs.writeFileSync('image.png', data); |
Oops, something went wrong.