Формы Xamarin: как перевести веб-сайт с помощью Microsoft Bing - PullRequest
0 голосов
/ 13 июля 2020

Я использую Microsoft Переводчик Bing ,

Мне удалось перевести текст, я хотел бы знать, как я могу перевести страницу html с URL

Вот мой код:

 static string host = "https://api.microsofttranslator.com";
        static string path = "/V2/Http.svc/Translate";

        // NOTE: Replace this example key with a valid subscription key.
        static string key = "xxxxx";

  public async Task<string> TranslateURL(string UrlToTranslate, string LanguageToTranslate)
            {
                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", key);

                string uri = host + path + "?to=" + LanguageToTranslate + "&text=" + System.Net.WebUtility.HtmlEncode(WordToTranslate);

                HttpResponseMessage response = await client.GetAsync(uri);

                string result = await response.Content.ReadAsStringAsync();
                // NOTE: A successful response is returned in XML. You can extract the contents of the XML as follows.
                var content = XElement.Parse(result).Value;
                return content;
            }

Заранее спасибо

...