feat: 必应验证码另一个解决方案

This commit is contained in:
ikechan8370 2023-07-28 14:20:55 +08:00
parent 51f786bd44
commit 12a94d8086
4 changed files with 68 additions and 45 deletions

View file

@ -1,9 +1,9 @@
import fetch from 'node-fetch'
// this file is deprecated
import { Config } from './config.js'
import {Config} from './config.js'
import HttpsProxyAgent from 'https-proxy-agent'
const newFetch = (url, options = {}) => {
const defaultOptions = Config.proxy
? {
@ -60,3 +60,27 @@ export async function solveCaptcha (id, regionId, text, token) {
}
}
}
export async function solveCaptchaOneShot (token) {
if (!token) {
throw new Error('no token')
}
let solveUrl = Config.bingCaptchaOneShotUrl
if (!solveUrl) {
throw new Error('no captcha source')
}
let result = await fetch(solveUrl, {
method: 'POST',
body: {
_U: token
}
})
if (result.status === 200) {
return await result.json()
} else {
return {
success: false,
error: result.statusText
}
}
}

View file

@ -131,6 +131,7 @@ const defaultConfig = {
serpSource: 'ikechan8370',
extraUrl: 'https://cpe.ikechan8370.com',
smartMode: false,
bingCaptchaOneShotUrl: 'http://bingcaptcha.ikechan8370.com/bing',
version: 'v2.7.3'
}
const _path = process.cwd()