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 = /