Google翻译Api

好久没来写帖子了,这次来搞个Google翻译

谷歌翻译挺好用的,在我看来这个谷歌翻译比其他的都要翻译的准确一点,由于总所周知的原因国内几乎是用不了谷歌翻译的,我刚好有台美国服务器,顺手反代了一波谷歌翻译,地址是 https://translate.s9y.in/ 有需要可以用,顺便提一嘴,我这个可以在idea插件translate里面使用

可是每次使用想使用都要打开网页再复制粘贴,真的太麻烦了,可是谷歌官方的api要收费,咱能省省,该花花,在我翻阅了相关文章之后,也是用我好久都没使用的go来写一下这个api,不得不说Java敲的我都快忘记go怎么写的了

不多说,上菜

api请求地址:https://translate.s9y.in/v1/translate
请求方式post
请求参数
{
    "be":"zh-CN",
    "to":"en",
    "message":"今天天气不错,我们出去玩耍",
    "type":0
}

be:你要传入的原语言
to:你要翻译成是语言
message:不多说
type:传入1是我处理之后返回,传入其他数字就是原返回内容

你问我为什么会单独写一个返回原内容,因为处理起来头大,下面贴几个返回内容,下面是我翻译的good


[[["好的","good",null,null,10],[null,null,"Hǎo de","ɡo͝od"]],[["形容词",["好","良好","优良","善","佳","良","乖","美","拿手","不赖","嘉","甜头","爽口","要得","姤","嫽","和蔼的","和蔼可亲的","合乎正道的","和善的","合适的"],[["好",["good"],null,0.19385885],["良好",["good","well","favorable","fine","favourable"],null,0.15822297],["优良",["excellent","good","fine","superior","exceptional","first-rate"],null,0.009651664],["善",["good","kind","friendly","virtuous","satisfactory"],null,0.006951832],["佳",["good","excellent","beautiful","fine"],null,0.006429394],["良",["good","beautiful","auspicious","docile"],null,0.003084857],["乖",["good","clever","perverse","alert","shrewd","well-behaved"],null,4.0464516E-4],["美",["beautiful","good","pretty"],null,2.9604472E-4],["拿手",["good","adept","expert"],null,2.0992715E-4],["不赖",["not bad","good"],null,3.944414E-5],["嘉",["fine","good","nice","great","outasite","perfect"],null,9.6662025E-6],["甜头",["sweet","good","pleasant"],null,5.338184E-6],["爽口",["tasty","delicious","tasty and refreshing","good","palatable","nice"],null,9.874648E-7],["要得",["fine","good","desirable"],null,6.179397E-7],["姤",["good"],null,2.496702E-7],["嫽",["good","smart"],null,2.496702E-7],["和蔼的",["agreeable","benevolent","benignant","cheerful","compassionate","good"]],["和蔼可亲的",["affable","agreeable","amiable","congenial","cooperative","good"]],["合乎正道的",["ethical","good","honest","just","moral","principled"]],["和善的",["benevolent","compassionate","good","good-hearted","humane","sympathetic"]],["合适的",["affable","agreeable","apposite","comfortable","enjoyable","good"]]],"good",3],["名词",["益处","臧","甜头","赢余","颛"],[["益处",["benefit","good","profit"],null,3.861151E-4],["臧",["good","well"],null,6.2409695E-6],["甜头",["good","sweet taste","pleasant flavor"],null,5.338184E-6],["赢余",["surplus","profit","excess","gain","good","remainder"],null,4.9652846E-7],["颛",["good","well"],null,2.496702E-7]],"good",1]],"en",null,null,[["good",null,[["好的",null,true,false,[10]],["善",null,true,false,[10]],["好",null,true,false,[2]],["良好",null,true,false,[2]],["很好",null,true,false,[8]]],[[0,4]],"good",0,0]],1,[],[["en"],null,[1],["en"]],null,null,[["形容词",[[["super","great","OK","hunky-dory","A1","ace","terrific","tremendous","fantastic","fab","supercalifragilisticexpialidocious","top-notch","tip-top","class","awesome","magic","wicked","brilliant","brill","smashing","bosting","on fleek","beaut","bonzer","spiffing","ripping","cracking","topping","top-hole","wizard","capital","champion","swell"],"m_en_gbus0422850.018",[["informal"]]],[["fine","of high quality","of a high standard","quality","superior","satisfactory","acceptable","adequate","in order","up to scratch","up to the mark","up to standard","up to par","competent","not bad","all right","excellent","superb","outstanding","magnificent","of the highest quality","of the highest standard","exceptional","marvelous","wonderful","first-rate","first-class","superlative","splendid","admirable","worthy","sterling"],"m_en_gbus0422850.018"],[["ambrosial"],"m_en_gbus0422850.018",[["literary"]]],[["ambrosian","nectareous","nectarean","flavorous","sapid"],"m_en_gbus0422850.018",[["rare"]]],[["scrumptious","delish","scrummy","yummy","yum-yum","moreish","peng","finger-licking","nummy"],"m_en_gbus0422850.018",[["informal"]]],[["delicious","mouthwatering","appetizing","tasty","flavorsome","flavorful","delectable","toothsome","inviting","enjoyable","palatable","succulent","luscious","rich","sweet","savory","piquant"],"m_en_gbus0422850.018"],[["valid","genuine","authentic","legitimate","sound","bona fide","convincing","persuasive","forceful","striking","telling","potent","powerful","strong","cogent","compelling","trenchant","weighty","important","meaningful","influential"],"m_en_gbus0422850.018"],[["great","mean","wicked","deadly","nifty","crack","super","ace","wizard","magic","crackerjack"],"m_en_gbus0422850.019",[["informal"]]],[["capable","able","proficient","adept","adroit","accomplished","seasoned","skillful","skilled","gifted","talented","masterly","virtuoso","expert","knowledgeable","qualified","trained"],"m_en_gbus0422850.019"],[["wholesome","health-giving","healthful","healthy","nourishing","nutritious","nutritional","strengthening","beneficial","salubrious","salutary"],"m_en_gbus0422850.021"],[["commodious","seasonable"],"m_en_gbus0422850.022",[["archaic"]]],[["convenient","suitable","appropriate","fitting","fit","suited","agreeable","opportune","timely","well timed","favorable","advantageous","expedient","felicitous","propitious","auspicious","happy","providential"],"m_en_gbus0422850.022"],[["squeaky clean"],"m_en_gbus0422850.026",[["informal"]]],[["virtuous","righteous","moral","morally correct","ethical","upright","upstanding","high-minded","right-minded","right-thinking","principled","exemplary","clean","law-abiding","lawful","irreproachable","blameless","guiltless","unimpeachable","just","honest","honorable","unbribable","incorruptible","anticorruption","scrupulous","reputable","decent","respectable","noble","lofty","elevated","worthy","trustworthy","meritorious","praiseworthy","commendable","admirable","laudable","pure","pure as the driven snow","whiter than white","sinless","saintly","saintlike","godly","angelic"],"m_en_gbus0422850.026"],[["kind","kindly","kindhearted","good-hearted","friendly","obliging","generous","charitable","magnanimous","gracious","sympathetic","benevolent","benign","altruistic","unselfish","selfless"],"m_en_gbus0422850.027"],[["well behaved","obedient","dutiful","well mannered","well brought up","polite","civil","courteous","respectful","deferential","manageable","compliant","acquiescent","tractable","malleable"],"m_en_gbus0422850.028"],[["meet","seasonable"],"m_en_gbus0422850.028",[["archaic"]]],[["right","correct","proper","decorous","seemly","appropriate","fitting","apt","suitable","convenient","expedient","favorable","auspicious","propitious","opportune","felicitous","timely","well judged","well timed"],"m_en_gbus0422850.028"],[["super","fantastic","fabulous","fab","terrific","glorious","grand","magic","out of this world","cool","brilliant","brill","smashing","peachy","neat","ducky","beaut","bonzer","capital","wizard","corking","spiffing","ripping","top-hole","topping","champion","beezer","swell"],"m_en_gbus0422850.034",[["informal"]]],[["enjoyable","pleasant","agreeable","pleasing","pleasurable","delightful","great","nice","lovely","amusing","diverting","jolly","merry","lively","festive","cheerful","convivial","congenial","sociable"],"m_en_gbus0422850.034"],[["frabjous"],"m_en_gbus0422850.034",[["rare"]]],[["dressy"],"m_en_gbus0422850.036",[["informal"]]],[["best","finest","newest","nice","nicest","smart","smartest","special","party","Sunday","formal"],"m_en_gbus0422850.036"],[["whole","full","entire","complete","solid","not less than","at least"],"m_en_gbus0422850.039"],[["not to be sneezed at","OK"],"m_en_gbus0422850.041",[["informal"]]],[["considerable","sizeable","substantial","appreciable","significant","goodly","tolerable","fair","reasonable","tidy","hefty","ample","plentiful","abundant","superabundant","great","large","lavish","profuse","generous","marked","noticeable"],"m_en_gbus0422850.041"],[["plenteous"],"m_en_gbus0422850.041",[["literary"]]]],"good",3],["名词",[[["virtue","righteousness","virtuousness","goodness","morality","ethicalness","uprightness","upstandingness","integrity","principle","dignity","rectitude","rightness","honesty","truth","truthfulness","honor","incorruptibility","probity","propriety","worthiness","worth","merit","irreproachableness","blamelessness","purity","pureness","lack of corruption","justice","justness","fairness"],"m_en_gbus0422850.050"],[["benefit","advantage","profit","gain","interest","welfare","well-being","enjoyment","satisfaction","comfort","ease","convenience","help","aid","assistance","use","usefulness","avail","service","behalf"],"m_en_gbus0422850.053"]],"good",1]],[["形容词",[["to be desired or approved of.","m_en_gbus0422850.011","a good quality of life"],["having the qualities required for a particular role.","m_en_gbus0422850.018","the schools here are good"],["possessing or displaying moral virtue.","m_en_gbus0422850.026","I've met many good people who made me feel ashamed of my own shortcomings"],["giving pleasure; enjoyable or satisfying.","m_en_gbus0422850.034","the streets fill up with people looking for a good time"],["thorough.","m_en_gbus0422850.038","have a good look around"],["(of a ticket) valid.","m_en_gbus0422850.043","the ticket is good for travel from May to September"],["used in conjunction with the name of God or a related expression as an exclamation of extreme surprise or anger.","m_en_gbus0422850.047","good heavens!"]],"good",3],["名词",[["that which is morally right; righteousness.","m_en_gbus0422850.050","a mysterious balance of good and evil"],["benefit or advantage to someone or something.","m_en_gbus0422850.053","he convinces his father to use his genius for the good of mankind"]],"good",1],["副词",[["well.","m_en_gbus0422850.062","my mother could never cook this good",[["informal"]]]],"good",4]],[[["\u003cb\u003egood\u003c/b\u003e heavens!",null,null,null,null,"m_en_gbus0422850.047"],["we live at peace with each other, which is \u003cb\u003egood\u003c/b\u003e",null,null,null,null,"m_en_gbus0422850.011"],["the attic needed a \u003cb\u003egood\u003c/b\u003e cleaning",null,null,null,null,"m_en_gbus0422850.038"],["it'll be \u003cb\u003egood\u003c/b\u003e and dark by then",null,null,null,null,"m_en_gbus0422850.040"],["he went upstairs to change out of his \u003cb\u003egood\u003c/b\u003e suit",null,null,null,null,"m_en_gbus0422850.036"],["the schools here are \u003cb\u003egood\u003c/b\u003e",null,null,null,null,"m_en_gbus0422850.018"],["the play had \u003cb\u003egood\u003c/b\u003e reviews",null,null,null,null,"m_en_gbus0422850.016"],["the rich and the \u003cb\u003egood\u003c/b\u003e shared the same fate as the poor and the bad",null,null,null,null,"m_en_gbus0422850.026"],["my mother could never cook this \u003cb\u003egood\u003c/b\u003e",null,null,null,null,"m_en_gbus0422850.062"],["a mysterious balance of \u003cb\u003egood\u003c/b\u003e and evil",null,null,null,null,"m_en_gbus0422850.050"],["they found him \u003cb\u003egood\u003c/b\u003e for a laugh",null,null,null,null,"m_en_gbus0422850.044"],["he was \u003cb\u003egood\u003c/b\u003e with children",null,null,null,null,"m_en_gbus0422850.019"],["we had a \u003cb\u003egood\u003c/b\u003e long hug",null,null,null,null,"m_en_gbus0422850.040"],["the \u003cb\u003egood\u003c/b\u003e people of the city were disconcerted",null,null,null,null,"m_en_gbus0422850.029"],["she speaks \u003cb\u003egood\u003c/b\u003e English",null,null,null,null,"m_en_gbus0422850.023"],["accustom the child to being rewarded for \u003cb\u003egood\u003c/b\u003e behavior",null,null,null,null,"m_en_gbus0422850.028"],["his money was \u003cb\u003egood\u003c/b\u003e for a bottle of whiskey",null,null,null,null,"m_en_gbus0422850.045"],["they're a \u003cb\u003egood\u003c/b\u003e twenty years younger",null,null,null,null,"m_en_gbus0422850.039"],["a \u003cb\u003egood\u003c/b\u003e quality of life",null,null,null,null,"m_en_gbus0422850.011"],["this is a \u003cb\u003egood\u003c/b\u003e month for planting seeds",null,null,null,null,"m_en_gbus0422850.022"],["the preservation of old buildings matters because they contribute to the general public \u003cb\u003egood\u003c/b\u003e",null,null,null,null,"m_en_gbus0422850.053"],["he was concerned with establishing and maintaining his \u003cb\u003egood\u003c/b\u003e name",null,null,null,null,"m_en_gbus0422850.031"],["he comes from a \u003cb\u003egood\u003c/b\u003e family",null,null,null,null,"m_en_gbus0422850.032"],["you're looking pretty \u003cb\u003egood\u003c/b\u003e",null,null,null,null,"m_en_gbus0422850.035"],["the ticket is \u003cb\u003egood\u003c/b\u003e for travel from May to September",null,null,null,null,"m_en_gbus0422850.043"],["too much sun is not \u003cb\u003egood\u003c/b\u003e for you",null,null,null,null,"m_en_gbus0422850.021"],["I am the eldest of five in a \u003cb\u003egood\u003c/b\u003e Catholic family",null,null,null,null,"m_en_gbus0422850.024"],["I'm \u003cb\u003egood\u003c/b\u003e at crosswords",null,null,null,null,"m_en_gbus0422850.019"],["there's a \u003cb\u003egood\u003c/b\u003e chance that we may be able to help you",null,null,null,null,"m_en_gbus0422850.041"],["have a \u003cb\u003egood\u003c/b\u003e look around",null,null,null,null,"m_en_gbus0422850.038"]]]]

看的我头大,还是不解析了
支持的语言,按理来说应该都支持只要你参数传递正确,不是传汉字哦

我顺手也将他的朗读接口也搞出来了,但是我懒得处理了,返回是一个音频对象
有时间我会直接更新接口,敬请期待吧。
开源地址:GitHub - 17Yuns/GoogleTranslate_API: google翻译api
好久没写go了代码写的乱,勿喷

29 个赞

并发咋样,高的话可以造个轮子来玩

1 个赞

没测试,你可以试试,不知道google会不会封ip

1 个赞

Thanks♪(・ω・)ノ

感谢,先mark了

历害了 佬 这是福利

1 个赞

感谢分享,收藏了 :tieba_002:

3 个赞

mark 在idea中用用看,么么哒
+1


这个需要管他?

1 个赞

去掉末尾的/

要测试成功才行


还是不得行


怎么会

image
这个插件


我用的也是这个tieba_009

开不开梯子都是一样的提示tieba_087

你是美国ip嘛,给拦截了

用正常网络就行

我都关掉啦 也查了下当前网络ip也是在国内 ,我换成手机热点试下看

只要你可以打开我的网站按理来说就不会出现这种问题