admin管理员组文章数量:1567750
Google翻译
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
namespace Google
{
class Program
{
static void Main(string[] args)
{
Google();
Console.ReadKey();
}
public static void Google()
{
string url = "https://translate.google/_/TranslateWebserverUi/data/batchexecute?rpcids=MkEWBc&bl=boq_translate-webserver_20210927.13_p0&soc-app=1&soc-platform=1&soc-device=1&rt=c";
string q = "The invention relates to a \"three-dimensional structure\" obtained from a tubular preform, which is obtained from a net of the Chebyshev type (with such a structure also being called \"elastic gridshell\") having a flared shape maintained by means selected from the group comprising hoops (5, 7, 9), spacers (11) and cables (11). The invention also relates to a method for installing such a structure, in which method the tubular preform is brought to the installation point, then deformations are applied to this preform that allow the final desired flared shape to be achieved. Particular application to the production of street furniture allowing shaded areas to be created in towns by cultivating everything that is fixed on a heavy container containing cultivated soil and the necessary devices.";
string from = "auto";
string to = "zh";
var from_data = "f.req=" + System.Web.HttpUtility.UrlEncode(
string.Format("[[[\"MkEWBc\",\"[[\\\"{0}\\\",\\\"{1}\\\",\\\"{2}\\\",true],[null]]\", null, \"generic\"]]]",
ReplaceString(q), from, to), Encoding.UTF8).Replace("+", "%20");
byte[] postData = Encoding.UTF8.GetBytes(from_data);
WebClient client = new WebClient();
client.Encoding = Encoding.UTF8;
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
client.Headers.Add("ContentLength", postData.Length.ToString());
client.Headers.Add("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9");
client.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36");
byte[] responseData = client.UploadData(url, "POST", postData);
string content = Encoding.UTF8.GetString(responseData);
Console.WriteLine(MatchResult(content));
}
/// <summary>
/// 匹配翻译结果
/// </summary>
/// <returns></returns>
public static string MatchResult(string content)
{
string result = "";
string patttern = @",\[\[\\\""(.*?)\\\"",";
Regex regex = new Regex(patttern);
MatchCollection matchcollection = regex.Matches(content);
if (matchcollection.Count > 0)
{
List<string> list = new List<string>();
foreach (Match match in matchcollection)
{
list.Add(match.Groups[1].Value);
}
版权声明:本文标题:C# 实现的几种在线翻译 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1725597585a1032032.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论