From 15f579aab8ecfa79adef3cc8e52c82a431d69d48 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Sun, 14 May 2023 13:24:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DPoe=20formkey=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/poe/credential.js | 4 ++-- utils/poe/index.js | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/utils/poe/credential.js b/utils/poe/credential.js index 572b0a2..b16a86d 100644 --- a/utils/poe/credential.js +++ b/utils/poe/credential.js @@ -4,7 +4,7 @@ import { readFileSync, writeFile } from 'fs' const scrape = async (pbCookie, proxy) => { let option = { headers: { cookie: `${pbCookie}` } } if (proxy) { - option.proxy = proxy + option.agent = proxy } const _setting = await fetch( 'https://poe.com/api/settings', @@ -24,7 +24,7 @@ const scrape = async (pbCookie, proxy) => { const getUpdatedSettings = async (channelName, pbCookie, proxy) => { let option = { headers: { cookie: `${pbCookie}` } } if (proxy) { - option.proxy = proxy + option.agent = proxy } const _setting = await fetch( `https://poe.com/api/settings?channel=${channelName}`, diff --git a/utils/poe/index.js b/utils/poe/index.js index 668b126..5a60356 100644 --- a/utils/poe/index.js +++ b/utils/poe/index.js @@ -58,7 +58,7 @@ export class PoeClient { this.config.app_settings = result.appSettings // set value - this.headers['poe-formkey'] = this.config.quora_formkey + this.headers['poe-formkey'] = this.config.quora_formkey // unused this.headers['poe-tchannel'] = this.config.channel_name this.headers.Cookie = this.config.quora_cookie console.log(this.headers) @@ -150,7 +150,9 @@ export class PoeClient { const nextData = JSON.parse(jsonText) this.nextData = nextData this.viewer = nextData.props.pageProps.payload.viewer - this.formkey = nextData.props.formkey + + this.formkey = this.extract_formkey(text) + this.headers['poe-formkey'] = this.formkey let bots = this.viewer.availableBots this.bots = {} for (let i = 0; i < bots.length; i++) { @@ -161,6 +163,24 @@ export class PoeClient { console.log(this.bots) } + extract_formkey (html) { + const scriptRegex = /