Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kenmueller/user-request
Simulate a user requesting an HTML page
https://github.com/kenmueller/user-request
Last synced: about 2 months ago
JSON representation
Simulate a user requesting an HTML page
- Host: GitHub
- URL: https://github.com/kenmueller/user-request
- Owner: kenmueller
- Created: 2020-07-28T12:06:57.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-01-06T08:10:23.000Z (almost 4 years ago)
- Last Synced: 2024-11-14T18:55:13.611Z (about 2 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/user-request
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# user-request
> Simulate a user requesting an HTML page
Perfect for web scraping, and allows retry attempts.
You're able to bypass CloudFlare protection by using `user-request`.
## Install
```bash
npm i user-request
```## Import
```js
const get = require('user-request')
```Or...
```ts
import * as get from 'user-request'
```## Instructions
### Call the `get` function with a URL to fetch that page.
```js
const response = await get('https://memorize.ai')
```### Pass options to the `get` function
```js
const response = await get('https://memorize.ai', {
maxRetryAttempts: 20, // Optional, 10 by default
headers: { // Optional, you can override or add headers here
'Accept-Encoding': 'gzip'
}
})
```### Properties on the `Response` object
- `data`: The page's HTML content.
- `headers`: The response headers.
- `status`: The status code.
- `statusText`: The status text.
- `retryAttempts`: The number of retry attempts this request took.
- `didFail`: If the request failed by either returning a 404 or 500, or running out of retry attempts.