doublewinter0 / xfyun-xinghuo

讯飞星火认知大模型 Web API
GNU General Public License v3.0
50 stars 3 forks source link

这个方法还是会被拦截 #1

Open heicathei opened 1 year ago

heicathei commented 1 year ago

我也尝试更换新的GtToken也不行,就必须得用官网发送一条消息然后半个小时有效,你可以参考一下https://github.com/chathub-dev/chathub/tree/main/src/app/bots/xunfei 我看他的这个就可以

doublewinter0 commented 1 year ago

你是通过 API 登录的吗?

heicathei commented 1 year ago

是的就是用的你的方法

doublewinter0 commented 1 year ago

我还特意等了两天,然后用我的账号测试了下,是没问题的。🤣

heicathei commented 1 year ago

Traceback (most recent call last): File "E:\新建文件夹\xfyun-xinghuo-main\src\iflygpt\core.py", line 172, in chat encoded_data += b'=' * (4 - missing_padding) TypeError: can only concatenate str (not "bytes") to str

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "E:\新建文件夹\xfyun-xinghuo-main\src\1.py", line 21, in asyncio.run(main()) File "D:\develop\Python\Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "D:\develop\Python\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\develop\Python\Lib\asyncio\base_events.py", line 650, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "E:\新建文件夹\xfyun-xinghuo-main\src\1.py", line 12, in main response = await bot.chat(4061597, text, bot.gt_token) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\develop\Python\Lib\contextlib.py", line 222, in aexit await self.gen.athrow(typ, value, traceback) File "D:\develop\Python\Lib\site-packages\httpx_client.py", line 1583, in stream yield response File "E:\新建文件夹\xfyun-xinghuo-main\src\iflygpt\core.py", line 176, in chat raise RequestError(encoded_data) iflygpt.exp.RequestError: 5L2g 这是你的代码我拿下来不能运行他可能有编码错误,然后我改了一下,但是应该不影响他的请求,你看下你的代码是不是没有正确上传

doublewinter0 commented 1 year ago

请求被拦截应该是这样的错误:iflygpt.exp.RequestError: [geeError];我看到你的错误是:iflygpt.exp.RequestError: 5L2g。代码可能有 bug,你可以 debug 追踪一下,我后续优化一下。

heicathei commented 1 year ago

你的这个我换了个账号确实可以,但是我两个账号只有一个正常,另一个依旧是半个小时就被拦截,很离谱,然后我很好奇你的这个GtToken是如果获取的 image

doublewinter0 commented 1 year ago

我的 GtToken 是抓包获取的。我刚才测试了下我的两个帐号,一个新号,一个老号,用的同一个 GtToken,都是 OK 的。

image image

heicathei commented 1 year ago

image 是从这个接口抓包抓的吗,我试了不行

doublewinter0 commented 1 year ago

是的,就是这个接口。你是一个帐号可以,一个不行吗?

heicathei commented 1 year ago

我的两个号,另一个号不是不行,他是半个小时之后还是会过期,我没找到原因,从这个抓出来的需要加两个==在结尾就可以了,刚刚试了抓包这个token在结尾加==是可以用的,我从别人的一个浏览器插件上找到了生成token的方法之前一直不行现在知道原因了,我再试试吧 image image 你可以参考一下,生成的参数是https://riskct.geetest.com/g2/api/v1/pre_load?client_type=web这个接口的 项目是这个项目https://github.com/chathub-dev/chathub/tree/main/src/app/bots/xunfei

doublewinter0 commented 1 year ago

我在抓包过程中也看到这个接口了,每次在请求 https://xinghuo.xfyun.cn/iflygpt-chat/u/chat_message/chat 接口前都会请求 https://riskct.geetest.com/g2/api/v1/pre_load 这个接口;根据 pro_load 接口返回的结果,我猜应该是调用某些 js 函数通过g_token这个参数生成了GtToken。我在测试过程中发现使用固定的 GtToken是可以的,所以就没有继续探究了。

GtTokenbase64 编码序列,末尾可能会有 == 符号。

supersaiyan2019 commented 1 year ago

一个账号的访问量超过某个值,就开始验证模式,避免服务器垮掉,所以新账号都畅通 chathub也有同样的issue话题 chatall的机制有点不同,但他带了前端,可以弹窗让用户拖 还是申请API走正规渠道吧

doublewinter0 commented 1 year ago

如果讯飞也走 OpenAI 那种运营模式,个人为此买单的可能性应该不高,使用 web 免费限量接口也是一种选择吧。 看讯飞会不会玩点新花样,静静等待吧!

boygoboy commented 1 year ago

这个GtToken是preload接口返回的加密文件加密的,可不是不变的,那个当前请求被拦截是跳了人机验证了

doublewinter0 commented 1 year ago

这个GtToken是preload接口返回的加密文件加密的,可不是不变的,那个当前请求被拦截是跳了人机验证了

目前使用固定的 GtToken 还是可以的,如果有好的 idea,欢迎提交 PR。

boygoboy commented 1 year ago

这个GtToken是preload接口返回的加密文件加密的,可不是不变的,那个当前请求被拦截是跳了人机验证了

目前使用固定的 GtToken 还是可以的,如果有好的 idea,欢迎提交 PR。

async loadAndExecuteRemoteFile(data) {
  try {
    const response = await axios.get(`https://static.geevisit.com${data.static_path}${data.js}`, {
      responseType: 'text',
    });
    console.log(response)
    if (response.status === 200) {
      const scriptContent = response.data;
     const script = document.createElement('script');
      script.innerHTML = scriptContent;
      document.body.appendChild(script);
      console.log('111111')
      console.log(window.GeeGuard)
        const token = await window.GeeGuard.load({
appId: 'ihuqg3dmuzcr2kmghumvivsk7c3l4joe',
js: data.js,
staticPath: data.static_path,
gToken: data.g_token,
type: 'gt',

}); console.log(token.gee_token) return token.gee_token // 现在你可以在这里调用远程脚本中的方法 // 例如:yourFunction(); } else { console.error(Failed to download file (Status Code: ${response.status})); } } catch (error) { console.error('Failed to download file:', error.message); } }, 类似这样就行了

doublewinter0 commented 1 year ago

这个GtToken是preload接口返回的加密文件加密的,可不是不变的,那个当前请求被拦截是跳了人机验证了

目前使用固定的 GtToken 还是可以的,如果有好的 idea,欢迎提交 PR。

async loadAndExecuteRemoteFile(data) {
  try {
    const response = await axios.get(`https://static.geevisit.com${data.static_path}${data.js}`, {
      responseType: 'text',
    });
    console.log(response)
    if (response.status === 200) {
      const scriptContent = response.data;
     const script = document.createElement('script');
      script.innerHTML = scriptContent;
      document.body.appendChild(script);
      console.log('111111')
      console.log(window.GeeGuard)
        const token = await window.GeeGuard.load({
appId: 'ihuqg3dmuzcr2kmghumvivsk7c3l4joe',
js: data.js,
staticPath: data.static_path,
gToken: data.g_token,
type: 'gt',

}); console.log(token.gee_token) return token.gee_token // 现在你可以在这里调用远程脚本中的方法 // 例如:yourFunction(); } else { console.error(Failed to download file (Status Code: ${response.status})); } } catch (error) { console.error('Failed to download file:', error.message); } }, 类似这样就行了

JavaScript 在这方面有天然优势,不过我不太熟悉。我抽空看下能不能转成 Python 脚本。感谢!