|
2 | 2 |
|
3 | 3 | `npm install scrapfly-sdk`
|
4 | 4 |
|
5 |
| -Quick use: |
| 5 | +## Quick Intro |
| 6 | + |
| 7 | +Get your API Key on [scrapfly.io/dashboard](https://scrapfly.io/dashboard) and start scraping: |
6 | 8 |
|
7 | 9 | ```javascript
|
8 |
| -import { ScrapflyClient, ScrapeConfig } from "scrapfly-sdk"; |
9 |
| - |
10 |
| -const client = new ScrapflyClient({key: "YOUR SCRAPFLY KEY"}); |
11 |
| -const result = await client.scrape(new ScrapeConfig({ |
12 |
| - url: "https://httpbin.dev/html", |
13 |
| - // optional: |
14 |
| - aps: true, // enable anti-scraping protection bypass |
15 |
| - render_js: true, // enable headless browsers for javascript rendering |
16 |
| - country: "us", // use a US proxy |
17 |
| - method: "GET", // use GET, POST or other type of requests |
18 |
| - data: {}, // what data to send if POST is used |
19 |
| - ... |
20 |
| -})) |
21 |
| -console.log(result.result.content) // html content |
| 10 | +import { ScrapflyClient, ScrapeConfig } from 'scrapfly-sdk'; |
| 11 | + |
| 12 | +const key = 'YOUR SCRAPFLY KEY'; |
| 13 | +const client = new ScrapflyClient({ key }); |
| 14 | +const apiResponse = await client.scrape( |
| 15 | + new ScrapeConfig({ |
| 16 | + url: 'https://web-scraping.dev/product/1', |
| 17 | + // optional parameters: |
| 18 | + // enable javascript rendering |
| 19 | + render_js: true, |
| 20 | + // set proxy country |
| 21 | + country: 'us', |
| 22 | + // enable anti-scraping protection bypass |
| 23 | + asp: true, |
| 24 | + // set residential proxies |
| 25 | + proxy_pool: 'public_residential_pool', |
| 26 | + // etc. |
| 27 | + }), |
| 28 | +); |
| 29 | +console.log(apiResponse.result.content); // html content |
22 | 30 | ```
|
23 | 31 |
|
24 |
| -See [/examples](./examples/) for more. |
25 |
| - |
26 |
| -## Get Your API Key |
27 |
| - |
28 |
| -You can create a free account on [Scrapfly](https://scrapfly.io/register) to get your API Key. |
29 |
| - |
30 |
| -- [Usage](https://scrapfly.io/docs/sdk/python) |
31 |
| -- [Python API](https://scrapfly.github.io/python-scrapfly/scrapfly) |
32 |
| -- [Open API 3 Spec](https://scrapfly.io/docs/openapi#get-/scrape) |
33 |
| -- [Scrapy Integration](https://scrapfly.io/docs/sdk/scrapy) |
34 |
| - |
| 32 | +For more see [/examples](/examples/) directory. |
| 33 | +For more on Scrapfly API see full documentation: <https://scrapfly.io/docs> |
| 34 | +For Python see [Scrapfly Python SDK](https://github.com/scrapfly/python-scrapfly) |
| 35 | + |
35 | 36 | ## Development
|
36 | 37 |
|
37 | 38 | Install and setup environment:
|
|
0 commit comments