ns-rss-spider 1.0.13 → 1.0.15
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.
|
@@ -105,7 +105,7 @@ async function parseContent($, $element, item, strategy) {
|
|
|
105
105
|
const content = (0, import_html_entities.decode)(elCont.trim());
|
|
106
106
|
if (!content) {
|
|
107
107
|
console.error(import_zx.chalk.red("解析 html 内容出错, html 如下"));
|
|
108
|
-
console.log(
|
|
108
|
+
console.log($.html());
|
|
109
109
|
return {
|
|
110
110
|
type: "simple",
|
|
111
111
|
content: "",
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
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
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/parsers/leiphone.ts
|
|
30
|
+
var leiphone_exports = {};
|
|
31
|
+
__export(leiphone_exports, {
|
|
32
|
+
leiphone: () => leiphone
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(leiphone_exports);
|
|
35
|
+
var import_axios = __toESM(require("axios"));
|
|
36
|
+
var import_zx = require("zx");
|
|
37
|
+
var import_cheerio = require("cheerio");
|
|
38
|
+
var import_constants = require("../utils/constants");
|
|
39
|
+
var leiphone = {
|
|
40
|
+
parse: true,
|
|
41
|
+
fetcher: "http",
|
|
42
|
+
getContentElementFromArticle: ($) => {
|
|
43
|
+
const el = $(".article-template .lph-article-comView");
|
|
44
|
+
return $(el);
|
|
45
|
+
},
|
|
46
|
+
getThumbs: async (articles) => {
|
|
47
|
+
const res = await import_axios.default.get("https://www.leiphone.com/", {
|
|
48
|
+
responseType: "text",
|
|
49
|
+
headers: {
|
|
50
|
+
"User-Agent": import_constants.chromeUA
|
|
51
|
+
}
|
|
52
|
+
}).catch((e) => {
|
|
53
|
+
console.error(import_zx.chalk.red("【get thumb】获取 html 错误"), e);
|
|
54
|
+
});
|
|
55
|
+
if (!res)
|
|
56
|
+
return void 0;
|
|
57
|
+
const html = res.data;
|
|
58
|
+
const $ = (0, import_cheerio.load)(html, null, false);
|
|
59
|
+
const kv = {};
|
|
60
|
+
$(".lph-pageList ul.clr > li .img > a:nth-child(2)").each((_, $a) => {
|
|
61
|
+
var _a;
|
|
62
|
+
const thumb = $($a).find("img").attr("data-original");
|
|
63
|
+
if (!thumb) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const href = $($a).attr("href") || "";
|
|
67
|
+
const guid = (_a = articles.find((a) => {
|
|
68
|
+
const r = a.guid == href;
|
|
69
|
+
return r;
|
|
70
|
+
})) == null ? void 0 : _a.guid;
|
|
71
|
+
if (guid && thumb) {
|
|
72
|
+
kv[guid] = thumb;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return kv;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
leiphone
|
|
81
|
+
});
|
package/dist/cjs/strategy.js
CHANGED
|
@@ -30,6 +30,7 @@ var import_kr = require("./parsers/36kr");
|
|
|
30
30
|
var import_techrunch = require("./parsers/techrunch");
|
|
31
31
|
var import_mydrivers = require("./parsers/mydrivers");
|
|
32
32
|
var import_tmtpost = require("./parsers/tmtpost");
|
|
33
|
+
var import_leiphone = require("./parsers/leiphone");
|
|
33
34
|
var strategies = {
|
|
34
35
|
cnbeta: import_cnbeta.cnbeta,
|
|
35
36
|
ifanr: import_ifanr.ifanr,
|
|
@@ -38,7 +39,8 @@ var strategies = {
|
|
|
38
39
|
"36kr": import_kr._36kr,
|
|
39
40
|
techrunch: import_techrunch.techrunch,
|
|
40
41
|
mydrivers: import_mydrivers.mydrivers,
|
|
41
|
-
tmtpost: import_tmtpost.tmtpost
|
|
42
|
+
tmtpost: import_tmtpost.tmtpost,
|
|
43
|
+
leiphone: import_leiphone.leiphone
|
|
42
44
|
};
|
|
43
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
46
|
0 && (module.exports = {
|