Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alsotang/superagentparse
https://github.com/alsotang/superagentparse
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/alsotang/superagentparse
- Owner: alsotang
- Created: 2014-04-23T10:15:24.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-09T08:58:58.000Z (about 10 years ago)
- Last Synced: 2024-10-06T16:48:28.244Z (3 months ago)
- Language: JavaScript
- Size: 215 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# superagentparse
This npm module is used to support encoding issue when using `superagent`.
## example
```js
var parse = require('superagentparse');superagent
.get('http://gbk_page_url/')
// here is the key, can be also:
// CP932, CP936, CP949, CP950, GB2313, GBK, GB18030, Big5, Shift_JIS, EUC-JP
.parse(parse('gbk'))
.end(function (err, res) {
res.text.should.equal('你好');
done(err);
});// when encoding is 'buffer', remember call `req.buffer(true)`
superagent
.get('https://www.google.com/images/srpr/logo11w.png')
.parse(parse('buffer'))
.buffer(true)
.end(function (err, res) {
Buffer.isBuffer(res.text).should.be.true;
done(err);
});
```for more infomation, please see: [encoding.js](test/encoding.js)