New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cheerio-httpcli

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cheerio-httpcli - npm Package Compare versions

Comparing version 0.6.6 to 0.6.7

test/reset.js

6

CHANGELOG.md

@@ -0,1 +1,7 @@

# 0.6.7 (2016-04-07)
* 依存ライブラリを最新バージョンに更新
* `reset()`メソッド追加
* 一部promiseのテストが機能していなかったのを修正
# 0.6.6 (2016-03-26)

@@ -2,0 +8,0 @@

4

lib/browsers.json
{
"ie": "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko",
"edge": "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36 Edge/12.10240",
"chrome": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36",
"firefox": "Mozilla/5.0 (Windows NT 6.1; rv:43.0) Gecko/20100101 Firefox/43.0",
"chrome": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36",
"firefox": "Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Firefox/45.0",
"opera": "Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; ja) Presto/2.10.289 Version/12.00",

@@ -7,0 +7,0 @@ "vivaldi": "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.43 Safari/537.36 Vivaldi/1.0.258.3",

@@ -1,2 +0,1 @@

/*eslint no-invalid-this:0*/
/*jshint -W100*/

@@ -3,0 +2,0 @@ 'use strict';

@@ -20,6 +20,2 @@ /*jshint -W100*/

// クッキー設定
var jar = request.jar();
request.defaults({ jar: jar });
/**

@@ -45,6 +41,7 @@ * <meta[http-equiv=refresh]>からURLを取得する正規表現

/*eslint-disable key-spacing*/
core : null, // cheerio-httpcli本体
encoding : null, // encodingモジュール
cheerio : null, // 拡張cheerioオブジェクト
engine : request, // requestモジュール
core : null, // cheerio-httpcli本体
encoding : null, // encodingモジュール
cheerio : null, // 拡張cheerioオブジェクト
engine : request, // requestモジュール
jar : request.jar(), // クッキー
/*eslint-enable key-spacing*/

@@ -57,2 +54,10 @@

/**
* プロパティや内部情報の初期化
*/
reset: function () {
// クッキーオブジェクト作り直し
this.jar = request.jar();
},
/**
* promise/callbackに両対応したエラー終了処理(promise実行後)

@@ -326,7 +331,10 @@ *

if (json.response && typeOf(json.cookies) === 'array') {
each(json.cookies, function (c) {
jar.setCookie(Cookie.fromJSON(c).toString(), json.response.request.uri.href);
});
each(json.cookies, (function (c) {
this.jar.setCookie(
Cookie.fromJSON(c).toString(),
json.response.request.uri.href
);
}).bind(this));
}
options.param.jar = jar;
options.param.jar = this.jar;

@@ -508,3 +516,3 @@ var err = (message) ? new Error(message) : null;

followRedirect: true,
jar: jar,
jar: this.jar,
secureOptions: constants.SSL_OP_NO_TLSv1_2 // とりあえず付けてみた

@@ -511,0 +519,0 @@ },

@@ -17,14 +17,4 @@ /*jshint -W100*/

*/
version: pkg.version, // バージョン情報
/*eslint-disable key-spacing*/
version : pkg.version, // バージョン情報
headers : {}, // リクエストヘッダ
timeout : 30000, // タイムアウトまでの時間(効いているかどうか不明)
gzip : true, // gzip転送する/しない
referer : true, // Refererを自動設定する/しない
followMetaRefresh : false, // <meta[http-equiv=refresh]>を検知してリダイレクトする/しない
maxDataSize : null, // 受信を許可する最大のサイズ
debug : false, // デバッグオプション
/*eslint-enable key-spacing*/
/**

@@ -35,2 +25,24 @@ * メソッド

/**
* プロパティや内部情報の初期化
*/
reset: function () {
// リクエストヘッダ
this.headers = {};
// タイムアウトまでの時間(効いているかどうか不明)
this.timeout = 30000;
// gzip転送する/しない
this.gzip = true;
// Refererを自動設定する/しない
this.referer = true;
// <meta[http-equiv=refresh]>を検知してリダイレクトする/しない
this.followMetaRefresh = false;
// 受信を許可する最大のサイズ
this.maxDataSize = null;
// デバッグオプション
this.debug = false;
client.reset();
},
/**
* 使用するiconvモジュールを指定

@@ -86,2 +98,3 @@ *

// clientオブジェクト内で使用する外部オブジェクトを登録
cheerioHttpCli.reset();
client.core = cheerioHttpCli;

@@ -88,0 +101,0 @@ client.encoding = encoding;

{
"name": "cheerio-httpcli",
"version": "0.6.6",
"version": "0.6.7",
"description": "http client module with cheerio & iconv(-lite) & promise",

@@ -23,3 +23,3 @@ "main": "index.js",

"foreach": "^2.0.5",
"he": "^0.5.0",
"he": "^1.0.0",
"iconv-lite": "^0.4.13",

@@ -30,3 +30,3 @@ "jschardet": "^1.4.1",

"prettyjson": "^1.1.3",
"request": "^2.69.0",
"request": "^2.70.0",
"require-uncached": "^1.0.2",

@@ -41,7 +41,7 @@ "rsvp": "^3.2.1",

"dev-null": "^0.1.1",
"eslint": "^2.5.1",
"eslint": "^2.7.0",
"espower-loader": "^1.0.0",
"intelli-espower-loader": "^1.0.1",
"isstream": "^0.1.2",
"istanbul": "^0.4.2",
"istanbul": "^0.4.3",
"jscs": "^2.11.0",

@@ -53,4 +53,5 @@ "leasot": "^3.2.2",

"power-assert": "^1.3.1",
"random-string": "^0.1.2",
"strip-ansi": "^3.0.1",
"yargs": "^4.3.2"
"yargs": "^4.4.0"
},

@@ -57,0 +58,0 @@ "repository": {

@@ -64,2 +64,3 @@ # cheerio-httpcli - Node.js用WEBスクレイピングモジュール

* [setIconvEngine()](#seticonvengineiconv-module-name)
* [reset()](#reset)
* [プロパティ](#%E3%83%97%E3%83%AD%E3%83%91%E3%83%86%E3%82%A3)

@@ -311,2 +312,8 @@ * [version](#version)

### reset()
cheerio-httpcliはシングルインスタンスで動作するモジュールなので、そのプロセスが動作している間は各種設定やクッキーを共有して保持し続けます。
`reset()`を実行すると、設定情報やクッキーをすべて初期化してプロセス起動時と同じ状態に戻します。
## プロパティ

@@ -336,3 +343,3 @@

`<meta http-equiv="refresh" content="0;URL=...">`といったMETAタグをHTML内に発見した場合に自動でそのURLにリダイレクトします。ただし、`<!--[if IE]>〜<![endif]-->`のようなIE条件付きコメント内にある場合はリダイレクトしません。デフォルトは`false`です。
`<meta http-equiv="refresh" content="0;URL=...">`といったMETAタグをHTML内に発見した場合に自動でそのURLにリダイレクトします。ただし、`<!--[if IE]>~<![endif]-->`のようなIE条件付きコメント内にある場合はリダイレクトしません。デフォルトは`false`です。

@@ -339,0 +346,0 @@ > Google検索をする場合は`followMetaRefresh`は`false`にしてください。

@@ -1,2 +0,2 @@

/*eslint max-statements:[1, 50]*/
/*eslint max-statements:[1, 100]*/
/*jshint -W100*/

@@ -8,2 +8,3 @@ var nstatic = require('node-static');

var each = require('foreach');
var random = require('random-string');
var fs = require('fs');

@@ -103,2 +104,14 @@ var qs = require('querystring');

if (/~session/.test(req.url)) {
// セッションID保持
var setCookie = (/x_session_id=/.test(req.headers.cookie || ''))
? req.headers.cookie
: ('x_session_id=user_' + random({ length: 32 }));
headers = [
[ 'Set-Cookie', setCookie ]
];
res.writeHead(200, headers);
return res.end('<html></html>');
}
if (/~redirect/.test(req.url)) {

@@ -105,0 +118,0 @@ // リダイレクト

@@ -25,3 +25,3 @@ /*eslint-env mocha*/

it('promiseによるfetchが正常に完了 => then->finallyが呼ばれる', function (done) {
it('promiseによるfetchが正常に完了 => then->finallyが呼ばれる', function () {
var called = 0;

@@ -40,7 +40,6 @@ return cli.fetch(helper.url('auto', 'shift_jis'))

assert(called === 1);
done();
});
});
it('promiseによるfetchでエラーが発生 => catch->finallyが呼ばれる', function (done) {
it('promiseによるfetchでエラーが発生 => catch->finallyが呼ばれる', function () {
var called = { then: 0, catch: 0 };

@@ -65,3 +64,2 @@ var url = helper.url('error', 'not-found');

assert.deepEqual(called, { then: 0, catch: 1 });
done();
});

@@ -92,3 +90,3 @@ });

it('promiseによるclickが正常に完了 => then->finallyが呼ばれる', function (done) {
it('promiseによるclickが正常に完了 => then->finallyが呼ばれる', function () {
var called = 0;

@@ -110,7 +108,6 @@ return cli.fetch(helper.url('form', 'utf-8'))

assert(called === 1);
done();
});
});
it('promiseによるclickでエラーが発生 => catch->finallyが呼ばれる', function (done) {
it('promiseによるclickでエラーが発生 => catch->finallyが呼ばれる', function () {
var called = { then: 0, catch: 0 };

@@ -135,7 +132,6 @@ return cli.fetch(helper.url('form', 'utf-8'))

assert.deepEqual(called, { then: 0, catch: 1 });
done();
});
});
it('promise作成前にclickエラーが発生 => catch->finallyが呼ばれる', function (done) {
it('promise作成前にclickエラーが発生 => catch->finallyが呼ばれる', function () {
var called = { then: 0, catch: 0 };

@@ -159,3 +155,2 @@ var url = helper.url('form', 'utf-8');

assert.deepEqual(called, { then: 0, catch: 1 });
done();
});

@@ -187,3 +182,3 @@ });

it('promiseによるclickが正常に完了 => then->finallyが呼ばれる', function (done) {
it('promiseによるclickが正常に完了 => then->finallyが呼ばれる', function () {
var called = 0;

@@ -205,11 +200,15 @@ return cli.fetch(helper.url('form', 'utf-8'))

assert(h['request-method'] === 'POST');
assert(h['post-data'] === 'checkbox=bbb&edit=' + encodeURIComponent('編集'));
var ep = 'text='
+ encodeURIComponent('あいうえお')
+ '&checkbox=bbb&edit='
+ encodeURIComponent('編集');
assert(h['post-data'] === ep);
})
.finally(function () {
assert(called === 1);
done();
});
});
it('promiseによるclickでエラーが発生 => catch->finallyが呼ばれる', function (done) {
it('promiseによるclickでエラーが発生 => catch->finallyが呼ばれる', function () {
var called = { then: 0, catch: 0 };

@@ -235,3 +234,2 @@ return cli.fetch(helper.url('form', 'utf-8'))

assert.deepEqual(called, { then: 0, catch: 1 });
done();
});

@@ -263,3 +261,3 @@ });

it('promiseによるclickが正常に完了 => then->finallyが呼ばれる', function (done) {
it('promiseによるclickが正常に完了 => then->finallyが呼ばれる', function () {
var called = 0;

@@ -281,11 +279,15 @@ return cli.fetch(helper.url('form', 'utf-8'))

assert(h['request-method'] === 'POST');
assert(h['post-data'] === 'checkbox=bbb&delete=' + encodeURIComponent('削除'));
var ep = 'text='
+ encodeURIComponent('あいうえお')
+ '&checkbox=bbb&delete='
+ encodeURIComponent('削除');
assert(h['post-data'] === ep);
})
.finally(function () {
assert(called === 1);
done();
});
});
it('promiseによるclickでエラーが発生 => catch->finallyが呼ばれる', function (done) {
it('promiseによるclickでエラーが発生 => catch->finallyが呼ばれる', function () {
var called = { then: 0, catch: 0 };

@@ -311,3 +313,2 @@ return cli.fetch(helper.url('form', 'utf-8'))

assert.deepEqual(called, { then: 0, catch: 1 });
done();
});

@@ -339,3 +340,3 @@ });

it('promiseによるclickが正常に完了 => then->finallyが呼ばれる', function (done) {
it('promiseによるclickが正常に完了 => then->finallyが呼ばれる', function () {
var called = 0;

@@ -357,11 +358,14 @@ return cli.fetch(helper.url('form', 'utf-8'))

assert(h['request-method'] === 'POST');
assert(h['post-data'] === 'checkbox=bbb&tweet=' + encodeURIComponent('ツイート'));
var ep = 'text='
+ encodeURIComponent('あいうえお')
+ '&checkbox=bbb&tweet.x=0&tweet.y=0';
assert(h['post-data'] === ep);
})
.finally(function () {
assert(called === 1);
done();
});
});
it('promiseによるclickでエラーが発生 => catch->finallyが呼ばれる', function (done) {
it('promiseによるclickでエラーが発生 => catch->finallyが呼ばれる', function () {
var called = { then: 0, catch: 0 };

@@ -387,3 +391,2 @@ return cli.fetch(helper.url('form', 'utf-8'))

assert.deepEqual(called, { then: 0, catch: 1 });
done();
});

@@ -390,0 +393,0 @@ });

@@ -118,4 +118,4 @@ /*eslint-env mocha*/

it('fetch(promise)からのclickSync => 非同期 -> 同期の流れでリンク先を取得する', function (done) {
cli.fetch(helper.url('form', 'utf-8'))
it('fetch(promise)からのclickSync => 非同期 -> 同期の流れでリンク先を取得する', function () {
return cli.fetch(helper.url('form', 'utf-8'))
.then(function (result1) {

@@ -127,3 +127,2 @@ var result2 = result1.$('.root').clickSync();

assert(typeOf(result2.body) === 'string');
done();
});

@@ -283,4 +282,4 @@ });

it('fetch(promise)からのclickSync => 非同期 -> 同期の流れでリンク先を取得する', function (done) {
cli.fetch(helper.url('form', 'utf-8'))
it('fetch(promise)からのclickSync => 非同期 -> 同期の流れでリンク先を取得する', function () {
return cli.fetch(helper.url('form', 'utf-8'))
.then(function (result1) {

@@ -295,3 +294,2 @@ var result2 = result1.$('form[name=post]').submitSync();

assert(typeOf(result2.body) === 'string');
done();
});

@@ -298,0 +296,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc