在C#.net中集成Google Translator [英] Integrate Google Translator in C#.net

查看:236
本文介绍了在C#.net中集成Google Translator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#.net中集成Google翻译器?



我访问了 http ://forum.codecall.net/topic/64790-c-tr​​anslator-using-google-api/ [ ^ ]但未解决

How do I integrate Google translator in C#.net?

I visited http://forum.codecall.net/topic/64790-c-translator-using-google-api/[^] but not solved

推荐答案

Google Translator is不再提供免费服务。相反,新API仅作为付费服务提供。有关更多信息,请参阅此处:



https://developers.google.com / translate / [ ^ ]



上面引用的代码可以使用旧的API,它不再可用。
The Google Translator is no longer available as a free service. Instead, the new API is only available as a paid service. See here for more information:

https://developers.google.com/translate/[^]

The code you referenced above would work with the old API, which is no longer available.


检查这^ ^ out
Check this^ out


如果您不想支付Google付费服务(请参阅Tim Corey的解决方案1),您可以仍然使用Google翻译网页本身, http://translate.google.com/ [ ^ ]。



您可以注意到,翻译并通过URL参数将语言ID传递到此页面。您可以使用类 System.Net.HttpWebRequest 发送HTTP请求,读取HTTP响应并解析它以提取转换。请参阅:

http://msdn.microsoft.com /en-us/library/system.net.httpwebrequest.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx [ ^ ](请参阅此处的HTTP代码示例)。



这有点难看,但会奏效。这是一个非常简单的 Web抓取的案例, http://en.wikipedia.org/wiki/Web_scraping [ ^ ]。



请参阅我过去对相关问题的回答:

从网页获取特定数据 [ ^ ],

如何从其他站点获取数据 [ ^ ]。



-SA
If you don''t want to pay for Google paid service (please see Solution 1 by Tim Corey), you can still use the Google Translate Web page itself, http://translate.google.com/[^].

As you can note, the text to be translated and language IDs are passed to this page via the URL parameters. You can send HTTP request using the class System.Net.HttpWebRequest, read HTTP response and parse it to extract the translation. Please see:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[^] (see HTTP code sample here).

This is a bit ugly but will work. This is a very simple case of Web scraping, http://en.wikipedia.org/wiki/Web_scraping[^].

Please see also my past answers to related questions:
get specific data from web page[^],
How to get the data from another site[^].

—SA


这篇关于在C#.net中集成Google Translator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆