如何使用 json 谷歌翻译 api?
我正在尝试使用来自 python 的 google 翻译和 utf-8 文本。 如何调用json api? 他们有一个将其嵌入 html 的文档,但我在任何地方都找不到合适的 API 或 wsdl。
谢谢 拉斐尔
I am trying to use google translate from python with utf-8 text.
How do I call the json api? They have a document for embedding it in html but I can't find a proper API or wsdl anywhere.
Thanks
Raphael
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是最终对我有用的代码。
使用没有ajax api的网站可能会导致你的ip被禁止,所以这样更好。
Here is the code that finally works for me.
Using the website without the ajax api can get your ip banned, so this is better.
使用 Peteris Kramins 的 xgoogle(他的博客)
Use xgoogle from Peteris Kramins (His blog)
看看我发现了什么:http://code.google.com/ intl/ru/apis/ajaxlanguage/terms.html
这是有趣的部分:
您不会,也不会允许您的最终用户或其他第三方:
....
* 提交长度超过5000个字符的任何请求;
....
Look what I have found : http://code.google.com/intl/ru/apis/ajaxlanguage/terms.html
Here is the interesting part:
You will not, and will not permit your end users or other third parties to:
....
* submit any request exceeding 5000 characters in length;
....
我认为您正在谈论 ajax api http://code.google.com/apis/ajaxlanguage/ ,
必须从javascript使用,所以我不明白“google从python翻译”是什么意思
或者如果您需要使用python的翻译功能,您可以直接查询翻译页面并使用xml/html库解析它例如美丽的汤,html5lib
实际上我做过一次,美丽的汤在谷歌翻译上不起作用,但在 html5lib(http ://code.google.com/p/html5lib/)
您是否需要执行类似的操作(从我的较大代码库复制)
I think you are talking about the ajax api http://code.google.com/apis/ajaxlanguage/,
which has to be used from javascript, so I do not understand what do you mean by "google translate from python"
Alternatively if you need to use translate functionality from python, you can directly query the translate page and parse it using xml/html libs e.g. beautiful soup, html5lib
Actually I did that once and beautiful soup did not work on google translate but html5lib(http://code.google.com/p/html5lib/) did
you will need to do something like this (copied from my larger code base)