翻译一些字符串使用谷歌翻译在winform c# winform

本文关键字:翻译 winform 谷歌 字符串 | 更新日期: 2023-09-27 17:53:37

我想在我的winform应用程序中翻译一个字符串。我想用谷歌翻译翻译一下。所以我的方法是使用"htmllagilitypack"使用抓取html方法。使用HTMLAgilityPack,我想在我的winform中将翻译后的字符串显示为标签。我用谷歌搜索了一下,但没有找到。我怎么能做到呢?我不想用谷歌翻译api来代替这个我这样尝试:

using HtmlAgilityPack; 
........
var webGet = new HtmlWeb();
var document = webGet.Load(
"http://translate.google.com/#en/bn/this%20is%20my%20string");
 var node = document.DocumentNode.SelectNodes(
"//span[@class='short_text' and @id='result_box']");
 if (node != null)
    {
  foreach (var xx in node)
   {
    x = xx.InnerText;
    MessageBox.Show(x);
   }
   }

翻译一些字符串使用谷歌翻译在winform c# winform

看一下这个关于如何使用Google API进行翻译的代码片段。