Esempio n. 1
0
        /// <summary>
        /// 中文翻译
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public List <string> GetData(string data)
        {
            List <string> list = new List <string>();

            if (!string.IsNullOrEmpty(data))
            {
                string url      = "http://fanyi.youdao.com/translate?&doctype=json&type=ZH_CN2EN&i=" + data;
                string jsonText = bc.Get_Http(url, 6000);
                try
                {
                    //解析json
                    JObject jObjet = JObject.Parse(jsonText);
                    int     i      = 0;
                    foreach (var item in jObjet)
                    {
                        string key = item.Key;
                        if (key.Equals("translateResult"))
                        {
                            JToken jToken = item.Value[0];
                            foreach (var value in jToken)
                            {
                                string str = value["tgt"].ToString().Replace(";", "");
                                list.Add(str);
                            }
                        }
                        i++;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(list);
        }