moto-faith / python

4 stars 2 forks source link

百度翻译不行了 #1

Open redstoneleo opened 5 years ago

redstoneleo commented 5 years ago

前两天我用你的百度翻译还可以 https://github.com/moto-faith/python/blob/master/baiduTranslate/test-54.py 我改了 'to': 'zh'

今天用起来就不正常了,比如输入的是 like a hot knife through butter 然而对此百度是有结果的 https://fanyi.baidu.com/#en/zh/like%20a%20hot%20knife%20through%20butter

moto-faith commented 5 years ago

我用这句话发现也是这样,程序生成的sign值:682254.952895,实际应该是:478354.241571,我以为是句子空格过多导致,但试了几个别的空格很多的句子也没问题,原因还在寻找......

redstoneleo commented 5 years ago

会不会是生成sign的算法不对,我看你的js里用的函数是e(),但是我看百度翻译的请求的https://fanyi.bdstatic.com/static/translation/pkg/index_607693f.js 这个js文件的628行起的内容,它用的是m()

var d = this
                  , a = this.processQuery(a)
                  , p = {
                    from: g.fromLang,
                    to: g.toLang,
                    query: a,
                    transtype: n,
                    simple_means_flag: 3,
                    sign: m(a),
                    token: window.common.token
                };
moto-faith commented 5 years ago

https://zhuanlan.zhihu.com/p/46111212 这是我找sign的过程。发现只有like a hot knife through butter得到的sign是错的,还有别的句子不能用吗?

redstoneleo commented 5 years ago

这个 He who pays the piper calls the tune

moto-faith commented 5 years ago

还是没能找出来为什么sign值不一样...写了一个谷歌翻译,这次应该可以翻译那些句子了:https://github.com/moto-faith/python/tree/master/googleTranslate

redstoneleo commented 5 years ago

大哥辛苦了! 根据我的经验,百度翻译对一些短句的翻译准确度好于谷歌翻译,谷歌翻译的长处在于大段英文翻译。