nodejs_chromium 1.1.8 → 1.1.11
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 +6 -4
- package/package.json +1 -1
- package/src/chrome.js +0 -1
package/index.js
CHANGED
|
@@ -4,7 +4,6 @@ const chrome = require("./src/chrome.js");
|
|
|
4
4
|
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
|
-
let browser;
|
|
8
7
|
const fs = require("fs");
|
|
9
8
|
|
|
10
9
|
|
|
@@ -98,7 +97,7 @@ async function newBrowser(params) {
|
|
|
98
97
|
if (!cache) option.args.push('--disable-cache'); //禁缓存
|
|
99
98
|
if (path) option.executablePath = path; //指定chrome安装路径
|
|
100
99
|
|
|
101
|
-
browser = await puppeteer.launch(option);
|
|
100
|
+
const browser = await puppeteer.launch(option);
|
|
102
101
|
|
|
103
102
|
await NormalClose(option.userDataDir); //禁止显示【要恢复页面吗?chromium 未正确关闭。】
|
|
104
103
|
|
|
@@ -107,7 +106,7 @@ async function newBrowser(params) {
|
|
|
107
106
|
catch (e) {
|
|
108
107
|
let mt = e.message.match(/\(ver\. (\d+\.\d+\.\d+\.\d+)\)/);
|
|
109
108
|
if (mt) {
|
|
110
|
-
return { error: `chrome(${mt})
|
|
109
|
+
return { error: `chrome(${mt[0]})未安装,请执行【npx puppeteer browsers install】以安装相应版本的chrome`, install: 1 };
|
|
111
110
|
}
|
|
112
111
|
else {
|
|
113
112
|
console.log('checkInstall', e.message);
|
|
@@ -129,7 +128,10 @@ async function newChrome(params) {
|
|
|
129
128
|
headers = {},
|
|
130
129
|
} = params;
|
|
131
130
|
|
|
132
|
-
await newBrowser(params);
|
|
131
|
+
const browser = await newBrowser(params);
|
|
132
|
+
if (browser.error) {
|
|
133
|
+
console.log({ browser })
|
|
134
|
+
}
|
|
133
135
|
|
|
134
136
|
// const version = await browser.version();
|
|
135
137
|
const page = (await browser.pages())[0];
|
package/package.json
CHANGED