admin管理员组文章数量:1336659
This code:
import puppeteer, { KnownDevices, Page } from "npm:puppeteer";
const browser = await puppeteer.launch({
executablePath: "C:/Users/ganuo/.cache/puppeteer/chrome/win64-125.0.6422.60/chrome-win64/chrome.exe",
headless: false,
userDataDir: "./user_data",
});
const page = await browser.newPage();
await page.emulate(KnownDevices["iPhone 15 Pro"]);
await page.goto(";);
const cookiesPath = "cookies.json";
try {
await Deno.lstat(cookiesPath);
const content = await Deno.readTextFile(cookiesPath);
const cookies = JSON.parse(content);
if (cookies.length !== 0) {
await page.setCookie(...cookies);
console.log("Session has been loaded in the browser");
}
} catch (error) {
console.error(error);
console.log("Create new cookies!");
const cookies = await page.cookies();
await Deno.writeTextFile(cookiesPath, JSON.stringify(cookies, null, 2));
console.log("Session has been saved to " + cookiesPath);
}
runs fine when there is no cookie, but yields this error in the second run:
Warning: Not implemented: ClientRequest.options.createConnection
Cookie exists!
ProtocolError: Protocol error (Network.deleteCookies): Invalid parameters Failed to deserialize params.partitionKey - BINDINGS: string value expected at position 355
at Callback.<instance_members_initializer> (file:///C:/Users/ganuo/AppData/Local/deno/npm/registry.npmjs/puppeteer-core/23.6.1/lib/esm/puppeteer/common/CallbackRegistry.js:89:14)
at new Callback (file:///C:/Users/ganuo/AppData/Local/deno/npm/registry.npmjs/puppeteer-core/23.6.1/lib/esm/puppeteer/common/CallbackRegistry.js:93:16)
at CallbackRegistry.create (file:///C:/Users/ganuo/AppData/Local/deno/npm/registry.npmjs/puppeteer-core/23.6.1/lib/esm/puppeteer/common/CallbackRegistry.js:19:26)
at Connection._rawSend (file:///C:/Users/ganuo/AppData/Local/deno/npm/registry.npmjs/puppeteer-core/23.6.1/lib/esm/puppeteer/cdp/Connection.js:86:26)
at CdpCDPSession.send (file:///C:/Users/ganuo/AppData/Local/deno/npm/registry.npmjs/puppeteer-core/23.6.1/lib/esm/puppeteer/cdp/CDPSession.js:63:33)
at CdpPage.deleteCookie (file:///C:/Users/ganuo/AppData/Local/deno/npm/registry.npmjs/puppeteer-core/23.6.1/lib/esm/puppeteer/cdp/Page.js:493:49)
at eventLoopTick (ext:core/01_core.js:214:9)
at async CdpPage.setCookie (file:///C:/Users/ganuo/AppData/Local/deno/npm/registry.npmjs/puppeteer-core/23.6.1/lib/esm/puppeteer/cdp/Page.js:515:9)
at async readCookie (file:///D:/QC supplements/Code/Apps/Xây nhân hiệu tự động/scr/Puppeteer.ts:54:7)
at async openBrowser (file:///D:/QC supplements/Code/Apps/Xây nhân hiệu tự động/scr/Puppeteer.ts:81:3) {
name: "ProtocolError",
message: "Protocol error (Network.deleteCookies): Invalid parameters Failed to deserialize params.partitionKey - BINDINGS: string value expected at position 355"
}
This similar question doesn't help.
本文标签:
版权声明:本文标题:javascript - Invalid parameters Failed to deserialize params.partitionKey - BINDINGS: string value expected at position X - Stac 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742420742a2471602.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论