-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ed3fdc
commit 701f766
Showing
3 changed files
with
25 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,9 @@ $ npm install got-scraping | |
``` | ||
|
||
**Note:** | ||
> - Node.js >=15.10.0 is required due to instability of HTTP/2 support in lower versions. | ||
> This project is ESM only, which means it can only be imported using the `import` statement or the `import()` method. It is not possible to `require()` it. | ||
> - Node.js >=16 is required due to instability of HTTP/2 support in lower versions. | ||
## API | ||
|
||
|
@@ -18,11 +20,22 @@ Got scraping package is built using the [`got.extend(...)`](https://github.com/s | |
Interested what's [under the hood](#under-the-hood)? | ||
|
||
```javascript | ||
const { gotScraping } = require('got-scraping'); | ||
import { gotScraping } from 'got-scraping'; | ||
|
||
gotScraping | ||
.get('https://apify.com') | ||
.then( ({ body }) => console.log(body)) | ||
.then( ({ body }) => console.log(body)); | ||
``` | ||
|
||
```javascript | ||
// If you're still using CJS and cannot use the import syntax | ||
let gotScraping; | ||
|
||
async function fetchWithGotScraping(url) { | ||
gotScraping ??= (await import('got-scraping')).gotScraping; | ||
|
||
return gotScraping.get(url); | ||
} | ||
``` | ||
### options | ||
|
@@ -34,14 +47,14 @@ Type: **`string`** | |
URL of the HTTP or HTTPS based proxy. HTTP/2 proxies are supported as well. | ||
```javascript | ||
const { gotScraping } = require('got-scraping'); | ||
import { gotScraping } from 'got-scraping'; | ||
|
||
gotScraping | ||
.get({ | ||
url: 'https://apify.com', | ||
proxyUrl: 'http://usernamed:[email protected]:1234', | ||
}) | ||
.then(({ body }) => console.log(body)) | ||
.then(({ body }) => console.log(body)); | ||
``` | ||
#### `useHeaderGenerator` | ||
|
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