nodejs_chromium 1.1.7 → 1.1.8
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/index.js +4 -5
- package/package.json +1 -1
- package/src/chrome.js +3 -1
package/index.js
CHANGED
|
@@ -5,11 +5,10 @@ const { exec } = require("child_process");
|
|
|
5
5
|
global.__UA__ = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36';
|
|
6
6
|
const mob_ua = 'Mozilla/5.0 (Linux; Android 13;Build/TKQ1.220905.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36';
|
|
7
7
|
let browser;
|
|
8
|
+
const fs = require("fs");
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
async function NormalClose(path) {
|
|
11
|
-
|
|
12
|
-
const fs = require("fs");
|
|
13
12
|
/**
|
|
14
13
|
* 禁止显示【要恢复页面吗?chromium 未正确关闭。】
|
|
15
14
|
* PATH为chrome.userDataDir
|
|
@@ -94,15 +93,15 @@ async function newBrowser(params) {
|
|
|
94
93
|
]
|
|
95
94
|
}
|
|
96
95
|
|
|
97
|
-
if (proxy) option.
|
|
96
|
+
if (proxy) option.args.push(`--proxy-server=${proxy}`);
|
|
98
97
|
if (incognito) option.args.push('--incognito', '--disable-infobars'); //使用无痕模式启动
|
|
99
98
|
if (!cache) option.args.push('--disable-cache'); //禁缓存
|
|
100
99
|
if (path) option.executablePath = path; //指定chrome安装路径
|
|
101
100
|
|
|
102
101
|
browser = await puppeteer.launch(option);
|
|
103
|
-
|
|
102
|
+
|
|
104
103
|
await NormalClose(option.userDataDir); //禁止显示【要恢复页面吗?chromium 未正确关闭。】
|
|
105
|
-
|
|
104
|
+
|
|
106
105
|
return browser;
|
|
107
106
|
}
|
|
108
107
|
catch (e) {
|
package/package.json
CHANGED
package/src/chrome.js
CHANGED
|
@@ -311,7 +311,9 @@ module.exports = class {
|
|
|
311
311
|
throw new Error(`${tag1} not exists`);
|
|
312
312
|
}
|
|
313
313
|
for (const elm of (await div.$$(tag2))) {
|
|
314
|
-
|
|
314
|
+
const html = await elm.evaluate(node => node.outerHTML);
|
|
315
|
+
const text = await elm.evaluate(node => node.innerHTML);
|
|
316
|
+
call(elm, { html, text });
|
|
315
317
|
}
|
|
316
318
|
}
|
|
317
319
|
catch (e) {
|