Comparing version 1.2.0 to 1.3.0
26
index.js
'use strict' | ||
const cheerio = require('cheerio') | ||
const got = require('got') | ||
const HttpsProxyAgent = require('https-proxy-agent') | ||
const fetch = require('node-fetch') | ||
@@ -12,6 +11,2 @@ module.exports = function (url, opts) { | ||
opts = opts || {} | ||
const proxy = opts.proxy === undefined ? | ||
process.env.http_proxy : | ||
opts.proxy | ||
const cheerioOpts = Object.assign({ | ||
@@ -21,13 +16,10 @@ // keep the original unicode chars | ||
}, opts.cheerio) | ||
const gotOptions = Object.assign({ | ||
agent: proxy && (new HttpsProxyAgent(proxy)) | ||
}, opts.got) | ||
const ret = got.get(url, gotOptions).then(data => { | ||
if (data.statusCode !== 200) { | ||
return Promise.reject(new Error(data.statusText)) | ||
} | ||
return data.body | ||
}) | ||
// normal mode, faster | ||
const ret = fetch(url) | ||
.then(data => { | ||
if (data.status !== 200) { | ||
return Promise.reject(new Error(data.statusText)) | ||
} | ||
return data.text() | ||
}) | ||
if (opts.htmlOnly) { | ||
@@ -34,0 +26,0 @@ return ret |
{ | ||
"name": "aimer", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Remote web content crawler done right.", | ||
@@ -27,8 +27,6 @@ "license": "MIT", | ||
"cheerio": "^0.20.0", | ||
"got": "^6.3.0", | ||
"https-proxy-agent": "^1.0.0" | ||
"node-fetch": "^1.5.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.14.0", | ||
"is-ci": "^1.0.9", | ||
"xo": "^0.15.0" | ||
@@ -35,0 +33,0 @@ }, |
@@ -41,12 +41,4 @@ # aimer [![NPM version](https://img.shields.io/npm/v/aimer.svg)](https://npmjs.com/package/aimer) [![NPM downloads](https://img.shields.io/npm/dm/aimer.svg)](https://npmjs.com/package/aimer) [![Circle CI](https://circleci.com/gh/egoist/aimer/tree/master.svg?style=svg)](https://circleci.com/gh/egoist/aimer/tree/master) | ||
##### got | ||
[got](https://github.com/sindresorhus/got) options, this module is used for retriving web contents. | ||
##### proxy | ||
An http or https proxy address, eg: `http://localhost:8787` for Lantern. If `process.env.http_proxy` is set and `opts.proxy` is not set we use the former. Set `opts.proxy` to `false` to disable proxy anyway. | ||
## License | ||
MIT © [EGOIST](https://github.com/egoist) |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
2
2
1
3594
25
44
2
+ Addednode-fetch@^1.5.1
+ Addedencoding@0.1.13(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addednode-fetch@1.7.3(transitive)
- Removedgot@^6.3.0
- Removedhttps-proxy-agent@^1.0.0
- Removedagent-base@2.1.1(transitive)
- Removedcapture-stack-trace@1.0.2(transitive)
- Removedcreate-error-class@3.0.2(transitive)
- Removeddebug@2.6.9(transitive)
- Removedduplexer3@0.1.5(transitive)
- Removedget-stream@3.0.0(transitive)
- Removedgot@6.7.1(transitive)
- Removedhttps-proxy-agent@1.0.0(transitive)
- Removedis-redirect@1.0.0(transitive)
- Removedis-retry-allowed@1.2.0(transitive)
- Removedlowercase-keys@1.0.1(transitive)
- Removedms@2.0.0(transitive)
- Removedprepend-http@1.0.4(transitive)
- Removedsemver@5.0.3(transitive)
- Removedtimed-out@4.0.1(transitive)
- Removedunzip-response@2.0.1(transitive)
- Removedurl-parse-lax@1.0.0(transitive)