ns-rss-spider 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/parse.d.ts +3 -16
- package/dist/cjs/parse.js +5 -3
- package/dist/cjs/parsers/ithome.js +50 -1
- package/dist/cjs/upload/index.d.ts +2 -2
- package/package.json +3 -2
package/dist/cjs/parse.d.ts
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
import { ServerInfo } from "./upload";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
storePath: any;
|
|
6
|
-
type: "rich" | "simple";
|
|
7
|
-
guid: string;
|
|
8
|
-
title: string;
|
|
9
|
-
link: string;
|
|
10
|
-
description: string;
|
|
11
|
-
pubDate: Date;
|
|
12
|
-
author?: string | undefined;
|
|
13
|
-
source?: string | undefined;
|
|
14
|
-
categories?: string | undefined;
|
|
15
|
-
thumb?: string | undefined;
|
|
16
|
-
}[];
|
|
17
|
-
thumbs: Record<string, string> | undefined;
|
|
2
|
+
export declare function parseRss(name: string, feed: string, server?: ServerInfo): Promise<{
|
|
3
|
+
contents: any[];
|
|
4
|
+
thumbs?: Record<string, string>;
|
|
18
5
|
}>;
|
package/dist/cjs/parse.js
CHANGED
|
@@ -58,15 +58,17 @@ async function parseRss(name, feed, server) {
|
|
|
58
58
|
console.log("after num", result.items.length);
|
|
59
59
|
}
|
|
60
60
|
if (!result.items.length) {
|
|
61
|
-
return
|
|
61
|
+
return {
|
|
62
|
+
contents: []
|
|
63
|
+
};
|
|
62
64
|
}
|
|
65
|
+
const contents = [];
|
|
66
|
+
const strategy = import_strategy.strategies[name];
|
|
63
67
|
result.items.forEach((item) => {
|
|
64
68
|
if (!item.guid) {
|
|
65
69
|
item.guid = item.link;
|
|
66
70
|
}
|
|
67
71
|
});
|
|
68
|
-
const strategy = import_strategy.strategies[name];
|
|
69
|
-
const contents = [];
|
|
70
72
|
for (let item of result.items) {
|
|
71
73
|
console.log(import_zx.chalk.green(`正在解析文章 【${item.title}】`));
|
|
72
74
|
if (!item.guid) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/parsers/ithome.ts
|
|
@@ -23,6 +33,9 @@ __export(ithome_exports, {
|
|
|
23
33
|
});
|
|
24
34
|
module.exports = __toCommonJS(ithome_exports);
|
|
25
35
|
var import_utils = require("../parseContent/utils");
|
|
36
|
+
var import_axios = __toESM(require("axios"));
|
|
37
|
+
var import_zx = require("zx");
|
|
38
|
+
var import_cheerio = require("cheerio");
|
|
26
39
|
var ithome = {
|
|
27
40
|
parse: true,
|
|
28
41
|
fetcher: "http",
|
|
@@ -44,7 +57,43 @@ var ithome = {
|
|
|
44
57
|
return $(el);
|
|
45
58
|
},
|
|
46
59
|
getExtraItems: async ($, rich, item) => {
|
|
47
|
-
|
|
60
|
+
const source = $("#source_baidu a").text();
|
|
61
|
+
return {
|
|
62
|
+
source
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
getThumbs: async (articles) => {
|
|
66
|
+
const res = await import_axios.default.get("https://m.ithome.com/", {
|
|
67
|
+
responseType: "text"
|
|
68
|
+
}).catch((e) => {
|
|
69
|
+
console.error(import_zx.chalk.red("获取 https://m.ithome.com/ 错误"), e);
|
|
70
|
+
});
|
|
71
|
+
if (!res)
|
|
72
|
+
return void 0;
|
|
73
|
+
const html = res.data;
|
|
74
|
+
const $ = (0, import_cheerio.load)(html, null, false);
|
|
75
|
+
const kv = {};
|
|
76
|
+
$(".content > .one-img-plc > a").each((_, $a) => {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
const thumb = $($a).find(".plc-image img").attr("data-original");
|
|
79
|
+
if (!thumb) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const href = $($a).attr("href") || "";
|
|
83
|
+
const reg = /([\d]+).htm/;
|
|
84
|
+
const articleId = (_a = reg.exec(href)) == null ? void 0 : _a[1];
|
|
85
|
+
const guid = (_b = articles.find((a) => {
|
|
86
|
+
const r = /([\d]+)\/([\d]+).htm/.exec(a.guid);
|
|
87
|
+
if (r && r[1] && r[2]) {
|
|
88
|
+
return `${r[1]}${r[2]}` === articleId;
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
})) == null ? void 0 : _b.guid;
|
|
92
|
+
if (guid && thumb) {
|
|
93
|
+
kv[guid] = thumb;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return kv;
|
|
48
97
|
}
|
|
49
98
|
};
|
|
50
99
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -12,14 +12,14 @@ export declare function uploadContent({ app, getUploadApi, items, }: {
|
|
|
12
12
|
items: Article[];
|
|
13
13
|
} & ServerInfo): Promise<Article[] | {
|
|
14
14
|
storePath: any;
|
|
15
|
-
|
|
15
|
+
source?: string | undefined;
|
|
16
|
+
type: "rich" | "simple";
|
|
16
17
|
guid: string;
|
|
17
18
|
title: string;
|
|
18
19
|
link: string;
|
|
19
20
|
description: string;
|
|
20
21
|
pubDate: Date;
|
|
21
22
|
author?: string | undefined;
|
|
22
|
-
source?: string | undefined;
|
|
23
23
|
categories?: string | undefined;
|
|
24
24
|
thumb?: string | undefined;
|
|
25
25
|
}[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ns-rss-spider",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"types": "dist/cjs/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"build": "father build",
|
|
11
11
|
"build:deps": "father prebundle",
|
|
12
12
|
"check": "father doctor",
|
|
13
|
-
"sync": "
|
|
13
|
+
"sync": "cnpm sync ns-rss-spider",
|
|
14
14
|
"pub": "npm run check && npm version patch && npm run build && npm publish --registry=https://registry.npmjs.org && git push origin master --tags && npm run sync"
|
|
15
15
|
},
|
|
16
16
|
"bin": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/lodash": "^4.14.202",
|
|
31
31
|
"@types/probe-image-size": "^7.2.4",
|
|
32
|
+
"cnpm": "^9.4.0",
|
|
32
33
|
"father": "^4.4.0",
|
|
33
34
|
"vitest": "^1.2.2"
|
|
34
35
|
},
|