Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kaelzhang/node-talking-bird
A simple but powerful and programable http agent to imitate requests from browsers.
https://github.com/kaelzhang/node-talking-bird
client http-agent mock
Last synced: 19 days ago
JSON representation
A simple but powerful and programable http agent to imitate requests from browsers.
- Host: GitHub
- URL: https://github.com/kaelzhang/node-talking-bird
- Owner: kaelzhang
- License: other
- Created: 2017-08-13T02:54:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-17T13:25:19.000Z (about 7 years ago)
- Last Synced: 2024-04-15T12:33:04.224Z (7 months ago)
- Topics: client, http-agent, mock
- Language: JavaScript
- Homepage:
- Size: 66.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/kaelzhang/node-talking-bird.svg?branch=master)](https://travis-ci.org/kaelzhang/node-talking-bird)
# talking-bird
A simple but powerful and programable http agent to imitate requests from browsers.
## Install
```sh
$ npm install talking-bird --save
```## Usage
```js
const browser = require('talking-bird')// Start a new session
const session = browser.session({
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1'
})const {
cookies,
ajax
} = await session.visit('http://dangerous.com')const url = 'http://dangerous.com/403-if-direct-access-without-sessionid-cookie'
const {
status
} = await ajax.request({url})console.log(status) // 200
// Oh Yeah!
```## browser.session(options)
Create a brand-new session with everything initialized.
Returns `Session`
**options**
- **userAgent** `String`
## session.visit(url)
Imitate a browser to visit a url, handles header
Returns `Promise.`
- `Promise.resolve` if the http status indicates successful
- otherwise `Promise.reject`## Struct: `Document`
- **response** `Object`
- **ajax** `Request`
- **cookies** `Cookie`## Class: `Request`
## Class: `Cookie`
## License
MIT