Socket
Socket
Sign inDemoInstall

cartoon-catch

Package Overview
Dependencies
21
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.1.1

dist/interface/helper.interface.js

4

dist/download.js

@@ -19,2 +19,3 @@ "use strict";

const debug_1 = __importDefault(require("debug"));
const setting_json_1 = __importDefault(require("../setting.json"));
const helper_1 = require("./helper");

@@ -98,3 +99,3 @@ const log = debug_1.default.debug('debug');

timeout: timeout + 300,
headers: Object.assign({ "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.3 Mobile/15E148 Safari/604.1" }, headers)
headers: Object.assign({ "User-Agent": setting_json_1.default.ua }, headers)
})

@@ -109,2 +110,1 @@ .then(res => res.body.pipe(writeStream))

exports.default = download;
//# sourceMappingURL=download.js.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHost = exports.isArray = exports.createFileName = void 0;
exports.getHtml = exports.getHost = exports.isArray = exports.createFileName = void 0;
const node_fetch_1 = __importDefault(require("node-fetch"));
const Iconv = __importStar(require("iconv-lite"));
const setting_json_1 = __importDefault(require("../../setting.json"));
function createFileName() {

@@ -17,2 +51,13 @@ return `${Date.now()}${Math.ceil(Math.random() * 5000 + 5000)}`;

exports.getHost = getHost;
//# sourceMappingURL=index.js.map
function getHtml(pageUrl, options) {
return __awaiter(this, void 0, void 0, function* () {
return yield node_fetch_1.default(pageUrl, {
method: 'get',
timeout: 5000,
headers: Object.assign({ "User-Agent": setting_json_1.default.ua }, options.headers)
})
.then((html) => __awaiter(this, void 0, void 0, function* () { return (options.encoding ? yield html.text() : yield html.buffer()); }))
.then((html) => typeof html === 'string' ? html : Iconv.decode(html, 'gb2312'));
});
}
exports.getHtml = getHtml;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=download.interface.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=main.interface.js.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -35,4 +16,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

const cheerio_1 = __importDefault(require("cheerio"));
const Iconv = __importStar(require("iconv-lite"));
const node_fetch_1 = __importDefault(require("node-fetch"));
const debug_1 = __importDefault(require("debug"));

@@ -47,9 +26,5 @@ const download_1 = __importDefault(require("./download"));

throw new Error('请输入target');
let html = yield node_fetch_1.default(pageUrl, {
method: 'get',
timeout: 5000,
headers: Object.assign({ "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.3 Mobile/15E148 Safari/604.1" }, options.headers)
let html = yield helper_1.getHtml(pageUrl, {
headers: options.headers
})
.then((html) => __awaiter(void 0, void 0, void 0, function* () { return (options.encoding ? yield html.text() : yield html.buffer()); }))
.then((html) => typeof html === 'string' ? html : Iconv.decode(html, 'gb2312'))
.catch(e => {

@@ -59,2 +34,4 @@ log(`请求超时 ${pageUrl} ${e}`);

});
if (!html)
return null;
const $ = cheerio_1.default.load(html);

@@ -89,9 +66,5 @@ const urls = $(options.target).toArray().map(item => {

log('发起请求', url);
result = yield node_fetch_1.default(url, {
method: 'get',
timeout: 5000,
headers: Object.assign({ "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.3 Mobile/15E148 Safari/604.1" }, options.headers)
result = yield helper_1.getHtml(url, {
headers: options.headers
})
.then((html) => __awaiter(void 0, void 0, void 0, function* () { return (options.encoding ? yield html.text() : yield html.buffer()); }))
.then((html) => options.encoding ? html : Iconv.decode(html, 'gb2312'))
.catch(e => {

@@ -127,2 +100,1 @@ log('请求超时', url, e);

exports.default = grap;
//# sourceMappingURL=main.js.map
{
"name": "cartoon-catch",
"version": "2.1.0",
"version": "2.1.1",
"description": "cartoon-catch",

@@ -5,0 +5,0 @@ "main": "dist/main.js",

@@ -5,2 +5,3 @@ import Progress from 'progress'

import Debug from 'debug'
import config from '../setting.json';
import { ImageInterface, OptionsInterface } from './interface/download.interface';

@@ -91,3 +92,3 @@ import { createFileName } from './helper';

headers: {
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.3 Mobile/15E148 Safari/604.1",
"User-Agent": config.ua,
...headers

@@ -94,0 +95,0 @@

@@ -1,10 +0,16 @@

function createFileName(){
import nodeFetch from 'node-fetch'
import * as Iconv from 'iconv-lite'
import config from '../../setting.json'
import { getHtmlInterface } from '../interface/helper.interface'
function createFileName(): string {
return `${Date.now()}${Math.ceil(Math.random() * 5000 + 5000)}`;
}
function isArray (t) {
function isArray (t: Object | Array<any>): boolean {
return Object.prototype.toString.call(t)== '[object Array]'
}
function getHost(url){
function getHost(url: string): string | null{
const urlArr = url.match(/^http(s)?:\/\/(.*?)\//);

@@ -14,6 +20,22 @@ return urlArr ? urlArr[0] : null;

async function getHtml(pageUrl: string, options: getHtmlInterface): Promise<string|null> {
return await nodeFetch(pageUrl, {
method: 'get',
timeout: 5000,
headers: {
"User-Agent": config.ua,
...options.headers
}
})
.then(async (html) => (options.encoding ? await html.text() : await html.buffer()))
.then((html: Buffer | string) => typeof html === 'string' ? html : Iconv.decode(html, 'gb2312'))
}
export {
createFileName,
isArray,
getHost
getHost,
getHtml
}

@@ -16,3 +16,3 @@ export interface ImageInterface {

againTimes: number
headers: any
headers: object
}
import cheerio from 'cheerio'
import * as Iconv from 'iconv-lite'
import nodeFetch from 'node-fetch'
import Debug from 'debug'
import download from './download'
import { OptionsInterface } from './interface/main.interface';
import { isArray, getHost } from './helper';
import { OptionsInterface } from './interface/main.interface'
import { isArray, getHost, getHtml } from './helper'
const log = Debug.debug('debug')

@@ -17,12 +14,5 @@

if(!options.target) throw new Error('请输入target');
let html = await nodeFetch(pageUrl, {
method: 'get',
timeout: 5000,
headers: {
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.3 Mobile/15E148 Safari/604.1",
...options.headers
}
let html = await getHtml(pageUrl, {
headers: options.headers
})
.then(async (html) => (options.encoding ? await html.text() : await html.buffer()))
.then((html: Buffer | string) => typeof html === 'string' ? html : Iconv.decode(html, 'gb2312'))
.catch(e => {

@@ -32,2 +22,3 @@ log(`请求超时 ${pageUrl} ${e}`)

});
if(!html) return null;
const $ = cheerio.load(html);

@@ -62,12 +53,5 @@ const urls = $(options.target).toArray().map(item => {

log('发起请求', url);
result = await nodeFetch(url, {
method: 'get',
timeout: 5000,
headers: {
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.3 Mobile/15E148 Safari/604.1",
...options.headers
}
result = await getHtml(url, {
headers: options.headers
})
.then(async (html) => (options.encoding ? await html.text() : await html.buffer()))
.then((html: any) => options.encoding ? html : Iconv.decode(html, 'gb2312'))
.catch(e => {

@@ -74,0 +58,0 @@ log('请求超时', url, e)

@@ -5,3 +5,3 @@ {

"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"sourceMap": true, /* Generates corresponding '.map' file. */
"sourceMap": false, /* Generates corresponding '.map' file. */
"outDir": "./dist", /* Redirect output structure to the directory. */

@@ -8,0 +8,0 @@ "noEmitOnError": true,

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc