姹夊瓧鏁版嵁瀛楀吀

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了姹夊瓧鏁版嵁瀛楀吀相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/ret' title='ret'>ret   娉ㄨВ   http   event   rac   led   pen   ber   get   

濡備綍鑾峰彇鍏ㄩ儴姹夊瓧鍙婃眽瀛楃殑璇︾粏淇℃伅锛?/p>

鍒氬垰鎵掍簡涓€閫氭眽瀛楀畬鏁寸殑鏁版嵁瀛楀吀锛宮ark浣滀笅璁板綍銆?/p>

鎵€鏈夋眽瀛楅泦鍚?/h2>

鎴戜滑鍖归厤涓枃瀛楃鏃讹紝缁忓父浣跨敤Unicode瀛楃"[^u4e00-u9fa5]"姝e垯琛ㄨ揪寮忔潵鏍¢獙銆?/p>

鍗佸叚杩涘埗锛屼粠4e00鍒?fa5锛岃浆鍖栦负鍗佽繘鍒跺悗锛屽彲鐭ュ叡鏈?0901涓眽瀛椼€?/p>

姹夊瓧鐨勯泦鍚堬紝鏄紑婧愮殑锛屽彲浠ョ洿鎺ヤ粠缃戜笂鑾峰彇銆?/p>

浠庝互涓婇摼鎺ヤ腑锛屼笅杞芥眽瀛楅泦鍚?/p>

鑾峰彇姹夊瓧淇℃伅

姹夊瓧鐨勮缁嗕俊鎭紝鍖呮嫭鎷奸煶/绗旂敾鏁?閮ㄩ/浜旂瑪杈撳叆/绗旈『缂栧彿/娉ㄨВ

缃戜笂鏈夌浉搴旂殑鏂板崕瀛楀吀Api鎺ュ彛锛岃繖閲岄€夌殑鏄?a href="https://www.juhe.cn/docs/api/id/156" target="_blank">鑱氬悎骞冲彴-鏂板崕瀛楀吀

閫氳繃浠栫殑C#婧愮爜,鎴戜滑鍙互鑾峰彇鍒版眽瀛楀瓧鍏哥殑璇︾粏淇℃伅

鎶€鏈垎浜浘鐗? src=

璇︾粏鏁版嵁璇风偣鍑?a href="https://files.cnblogs.com/files/kybs0/%E6%B1%89%E5%AD%97%E6%95%B0%E6%8D%AE%E5%AD%97%E5%85%B8All.rar" target="_blank">涓嬭浇

PS:

  • 閮ㄩ鍜屼簲绗旈兘鏈変负绌猴紝閮ㄩ杩斿洖鐨勬暟鎹负锛?闅炬瀛?銆?/li>
  • 绗旈『缂栧彿鍙€氳繃杩斿洖鐨勭畝瑙d腑寰楀埌銆傜瑪椤虹紪鍙凤紝鍗虫寚姣忎釜绗旂敾瀵瑰簲鐨勫彿鐮侊紝杩欎釜闈炲父鏈夌敤锛?/li>

鑱氬悎鎺ュ彛-姹夊瓧

鑾峰彇姹夊瓧锛?/p>

 1         public static HanziDetail FindHanzi(string hanzi)
 2         {
 3             //1.鏍规嵁姹夊瓧鏌ヨ瀛楀吀
 4             string url1 = "http://v.juhe.cn/xhzd/query";
 5 
 6             var parameters1 = new Dictionary<string, string>();
 7 
 8             parameters1.Add("word", hanzi); //濉啓闇€瑕佹煡璇㈢殑姹夊瓧锛孶TF8 urlencode缂栫爜
 9             parameters1.Add("key", "XXXXXX");//浣?/span>鐢宠鐨刱ey
10             parameters1.Add("dtype", ""); //杩斿洖鏁版嵁鐨勬牸寮?xml鎴杍son锛岄粯璁son
11 
12             string result2 = SendPost(url1, parameters1, "get");
13 
14             var hanziRequestResponse = JsonConvert.DeserializeObject<HanziRequestResponse>(result2);
15 
16             //HanziDetail hanziDetail = null;
17             //if (hanziRequestResponse.ErrorCode == "0" && hanziRequestResponse.Result != null)
18             //{
19             //    hanziDetail = hanziRequestResponse.Result;
20             //}
21 
22             return hanziRequestResponse.Result;
23         }
24     }

瑙f瀽绫伙細

鎶€鏈垎浜浘鐗? id=
 1     [DataContract]
 2     public class HanziRequestResponse
 3     {
 4         [DataMember(Name = "reason")]
 5         public string Reason { get; set; }
 6 
 7         [DataMember(Name = "error_code")]
 8         public string ErrorCode { get; set; }
 9 
10         [DataMember(Name = "result")]
11         public HanziDetail Result { get; set; }
12     }
13     [DataContract]
14     public class HanziDetail
15     {
16         [DataMember(Name = "zi")]
17         public string Hanzi { get; set; }
18 
19         /// <summary>
20         /// 閮ㄩ
21         /// </summary>
22         [DataMember(Name = "bushou")]
23         public string Radical { get; set; }
24 
25         /// <summary>
26         /// 鎷奸煶
27         /// </summary>
28         [DataMember(Name = "pinyin")]
29         public string Pinyin { get; set; }
30 
31         /// <summary>
32         /// 绗旂敾鏁?
33         /// </summary>
34         [DataMember(Name = "bihua")]
35         public string Bihua { get; set; }
36 
37         /// <summary>
38         /// 浜旂瑪
39         /// </summary>
40         [DataMember(Name = "wubi")]
41         public string WuBi { get; set; }
42 
43         /// <summary>
44         /// 鏋佺畝浠嬬粛
45         /// </summary>
46         [DataMember(Name = "jijie")]
47         public List<string> SimpleDetailContent { get; set; }
48     }
View Code

璇︾粏鐨勬簮鐮丏emo锛屽彲鐐瑰嚮涓嬭浇

以上是关于姹夊瓧鏁版嵁瀛楀吀的主要内容,如果未能解决你的问题,请参考以下文章

绋嬪簭鎬ц兘浼樺寲涔嬬綉缁滀紶杈撲笌鏁版嵁瀛樺偍浼樺寲锛堜簲锛変笅

鍒濊瘑Protobuf

python瀛︿範绡?5 - 瀛楀吀 闆嗗悎

Python瀛楀吀閲岀殑5涓粦榄旀硶

瀛楀吀鑴氭湰鍜孧D5鐖嗙牬鑴氭湰

Java鎿嶄綔JSON鏁版嵁--Gson鎿嶄綔JSON鏁版嵁