Skip to content

Commit

Permalink
feat: 更改BING_HEADER获取方式
Browse files Browse the repository at this point in the history
  • Loading branch information
weaigc committed Aug 3, 2023
1 parent 0750a26 commit dabc286
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ docker run --rm -it -e BING_HEADER=xxxx -p 7860:7860 bingo
```

## 如何获取 BING_HEADER
打开 https://www.bing.com 并登录,然后访问 https://www.bing.com/turing/conversation/create
打开 https://www.bing.com 并登录,然后访问 https://www.bing.com/turing/captcha/challenge,通过人机校验,然后

![BING HEADER](./docs/images/curl.png)

Expand All @@ -136,7 +136,7 @@ docker run --rm -it -e BING_HEADER=xxxx -p 7860:7860 bingo
<summary>正常格式/网页端保存的格式(格式仅供参考)</summary>

```
curl 'https://www.bing.com/turing/conversation/create' \
curl 'https://www.bing.com/turing/captcha/challenge' \
-H 'authority: www.bing.com' \
-H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' \
-H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6' \
Expand Down
Binary file modified docs/images/curl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function Settings() {
打开并登录 Bing
</ExternalLink>
,然后再打开
<ExternalLink href="https://www.bing.com/turing/conversation/create">Create 接口</ExternalLink>
<ExternalLink href="https://www.bing.com/turing/captcha/challenge">Challenge 接口</ExternalLink>
右键 》检查。打开开发者工具,在网络里面找到 Create 接口 》右键复制》复制为 cURL(bash),粘贴到此处,然后保存。
<div className="h-2" />
图文示例:
Expand All @@ -55,7 +55,7 @@ export function Settings() {
</div>
<Input
value={curlValue}
placeholder="在此填写用户信息,格式: curl 'https://www.bing.com/turing/conversation/create' ..."
placeholder="在此填写用户信息,格式: curl 'https://www.bing.com/turing/captcha/challenge' ..."
onChange={e => setCurlValue(e.target.value)}
/>
<Button variant="ghost" className="bg-[#F5F5F5] hover:bg-[#F2F2F2]" onClick={() => copyToClipboard(btoa(curlValue))}>
Expand All @@ -68,7 +68,7 @@ export function Settings() {
className="bg-[#c7f3ff] hover:bg-[#fdc7ff]"
onClick={() => {
if (curlValue) {
if (!/^\s*curl /.test(curlValue)) {
if (!/^\s*curl ['"]https:\/\/www\.bing\.com\/turing\/captcha\/challenge['"]/.test(curlValue)) {
toast.error('格式不正确')
return
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bots/bing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export class BingWebBot {
},
}

if (imageUrl.startsWith('data:image/jpeg;base64,')) {
if (imageUrl.startsWith('data:image/')) {
imageBase64 = imageUrl.replace('data:image/', '');
const partIndex = imageBase64.indexOf(',')
if (partIndex) {
Expand Down
7 changes: 0 additions & 7 deletions src/lib/isomorphic/node.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import Debug from 'debug'

// const safeRequire = (path: string) => {
// try {
// return eval(`require("${path}")`) || {}
// } catch (e) {}
// return {}
// }

const { fetch, setGlobalDispatcher, ProxyAgent } = require('undici')
const { HttpsProxyAgent } = require('https-proxy-agent')
const ws = require('ws')
Expand Down
4 changes: 2 additions & 2 deletions src/pages/api/kblob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { fetch } from '@/lib/isomorphic'
import { KBlobRequest } from '@/lib/bots/bing/types'
import FormData from 'form-data'

// const API_DOMAIN = 'https://www.bing.com'
const API_DOMAIN = 'https://bing.vcanbb.top'
const API_DOMAIN = 'https://www.bing.com'
// const API_DOMAIN = 'https://bing.vcanbb.top'

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/api/sydney.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { WebSocket } from '@/lib/isomorphic';
import { WebSocket, debug } from '@/lib/isomorphic';
import { BingWebBot } from '@/lib/bots/bing';
import { websocketUtils } from '@/lib/bots/bing/utils';
import { WatchDog, createHeaders } from '@/lib/utils';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const conversationContext = req.body
const headers = createHeaders(req.cookies)

debug(headers)
res.setHeader('Content-Type', 'text/stream; charset=UTF-8')

const ws = new WebSocket('wss://sydney.bing.com/sydney/ChatHub', {
Expand Down

0 comments on commit dabc286

Please sign in to comment.