Open heicathei opened 1 year ago
你是通过 API 登录的吗?
是的就是用的你的方法
我还特意等了两天,然后用我的账号测试了下,是没问题的。🤣
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
请求被拦截应该是这样的错误:iflygpt.exp.RequestError: [geeError]
;我看到你的错误是:iflygpt.exp.RequestError: 5L2g
。代码可能有 bug,你可以 debug 追踪一下,我后续优化一下。
你的这个我换了个账号确实可以,但是我两个账号只有一个正常,另一个依旧是半个小时就被拦截,很离谱,然后我很好奇你的这个GtToken是如果获取的
我的 GtToken 是抓包获取的。我刚才测试了下我的两个帐号,一个新号,一个老号,用的同一个 GtToken,都是 OK 的。
是从这个接口抓包抓的吗,我试了不行
是的,就是这个接口。你是一个帐号可以,一个不行吗?
我的两个号,另一个号不是不行,他是半个小时之后还是会过期,我没找到原因,从这个抓出来的需要加两个==在结尾就可以了,刚刚试了抓包这个token在结尾加==是可以用的,我从别人的一个浏览器插件上找到了生成token的方法之前一直不行现在知道原因了,我再试试吧
你可以参考一下,生成的参数是https://riskct.geetest.com/g2/api/v1/pre_load?client_type=web这个接口的
项目是这个项目https://github.com/chathub-dev/chathub/tree/main/src/app/bots/xunfei
我在抓包过程中也看到这个接口了,每次在请求 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
是可以的,所以就没有继续探究了。
GtToken 是 base64 编码序列,末尾可能会有 == 符号。
一个账号的访问量超过某个值,就开始验证模式,避免服务器垮掉,所以新账号都畅通 chathub也有同样的issue话题 chatall的机制有点不同,但他带了前端,可以弹窗让用户拖 还是申请API走正规渠道吧
如果讯飞也走 OpenAI 那种运营模式,个人为此买单的可能性应该不高,使用 web 免费限量接口也是一种选择吧。 看讯飞会不会玩点新花样,静静等待吧!
这个GtToken是preload接口返回的加密文件加密的,可不是不变的,那个当前请求被拦截是跳了人机验证了
这个GtToken是preload接口返回的加密文件加密的,可不是不变的,那个当前请求被拦截是跳了人机验证了
目前使用固定的 GtToken 还是可以的,如果有好的 idea,欢迎提交 PR。
这个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);
}
}, 类似这样就行了
这个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 脚本。感谢!
我也尝试更换新的GtToken也不行,就必须得用官网发送一条消息然后半个小时有效,你可以参考一下https://github.com/chathub-dev/chathub/tree/main/src/app/bots/xunfei 我看他的这个就可以