fix: poe添加proxy支持

This commit is contained in:
ikechan8370 2023-05-14 12:47:20 +08:00
parent 63f8629037
commit 1a94d92943
3 changed files with 43 additions and 33 deletions

View file

@ -1,10 +1,14 @@
import fetch from 'node-fetch'
import { readFileSync, writeFile } from 'fs'
const scrape = async (pbCookie) => {
const scrape = async (pbCookie, proxy) => {
let option = { headers: { cookie: `${pbCookie}` } }
if (proxy) {
option.proxy = proxy
}
const _setting = await fetch(
'https://poe.com/api/settings',
{ headers: { cookie: `${pbCookie}` } }
option
)
if (_setting.status !== 200) throw new Error('Failed to fetch token')
const appSettings = await _setting.json()
@ -17,10 +21,14 @@ const scrape = async (pbCookie) => {
}
}
const getUpdatedSettings = async (channelName, pbCookie) => {
const getUpdatedSettings = async (channelName, pbCookie, proxy) => {
let option = { headers: { cookie: `${pbCookie}` } }
if (proxy) {
option.proxy = proxy
}
const _setting = await fetch(
`https://poe.com/api/settings?channel=${channelName}`,
{ headers: { cookie: `${pbCookie}` } }
option
)
if (_setting.status !== 200) throw new Error('Failed to fetch token')
const appSettings = await _setting.json()