123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- using Newtonsoft.Json;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Security.Cryptography;
- using System.Text;
- namespace PublicLibrary
- {
- public static class KuaiDi100
- {
- //http://www.kuaidi100.com/query?type=shentong&postid=3397565624265
- //http://www.kuaidi100.com/autonumber/auto?num=3397565624265&key=kPxmJCvS5025
- public static KuaiDiRoot Query(string kdcode)
- {
- HttpClient httpClient = new HttpClient();
- var httpResponseMessage = httpClient.GetAsync($"http://www.kuaidi100.com/autonumber/auto?num={kdcode}&key=kPxmJCvS5025").Result;
- var result = httpResponseMessage.Content.ReadAsStringAsync().Result;
- if (!string.IsNullOrEmpty(result) && result != "[]")
- {
- var list = JsonConvert.DeserializeObject<List<AutoNumber>>(result);
- var comCode = list.First().comCode;
- var str = $"http://www.kuaidi100.com/query?type={comCode}&postid={kdcode}";
- var web = WebRequest.Create(str);
- web.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0");
- var stream = web.GetResponse().GetResponseStream();
- StreamReader sr = new StreamReader(stream);
- string result2 = sr.ReadToEnd();
- var root = JsonConvert.DeserializeObject<KuaiDiRoot>(result2);
- return root;
- }
- return null;
- }
- class AutoNumber
- {
- public string comCode { get; set; }
- public string id { get; set; }
- public string noCount { get; set; }
- public string noPre { get; set; }
- public string startTime { get; set; }
- }
- public class KuaiDiData
- {
- public DateTime time { get; set; }
- public DateTime ftime { get; set; }
- public string context { get; set; }
- public string location { get; set; }
- }
- public class KuaiDiRoot
- {
- public string message { get; set; }
- public string nu { get; set; }
- public string ischeck { get; set; }
- public string condition { get; set; }
- public string com { get; set; }
- public string status { get; set; }
- public string state { get; set; }
- public List<KuaiDiData> data { get; set; }
- }
- }
- enum KuaiDiCode
- {
- [Description("aae全球专递")]
- aae,
- [Description("安捷快递")]
- anjie,
- [Description("安信达快递")]
- anxindakuaixi,
- [Description("彪记快递")]
- biaojikuaidi,
- [Description("bht")]
- bht,
- [Description("百福东方国际物流")]
- baifudongfang,
- [Description("中国东方(COE)")]
- coe,
- [Description("长宇物流")]
- changyuwuliu,
- [Description("大田物流")]
- datianwuliu,
- [Description("德邦物流")]
- debangwuliu,
- [Description("dhl")]
- dhl,
- [Description("dpex")]
- dpex,
- [Description("d速快递")]
- dsukuaidi,
- [Description("递四方")]
- disifang,
- [Description("ems快递")]
- ems,
- [Description("fedex(国外)")]
- fedex,
- [Description("飞康达物流")]
- feikangda,
- [Description("凤凰快递")]
- fenghuangkuaidi,
- [Description("飞快达")]
- feikuaida,
- [Description("国通快递")]
- guotongkuaidi,
- [Description("港中能达物流")]
- ganzhongnengda,
- [Description("广东邮政物流")]
- guangdongyouzhengwuliu,
- [Description("共速达")]
- gongsuda,
- [Description("汇通快运")]
- huitongkuaidi,
- [Description("恒路物流")]
- hengluwuliu,
- [Description("华夏龙物流")]
- huaxialongwuliu,
- [Description("海红")]
- haihongwangsong,
- [Description("海外环球")]
- haiwaihuanqiu,
- [Description("佳怡物流")]
- jiayiwuliu,
- [Description("京广速递")]
- jinguangsudikuaijian,
- [Description("急先达")]
- jixianda,
- [Description("佳吉物流")]
- jjwl,
- [Description("加运美物流")]
- jymwl,
- [Description("金大物流")]
- jindawuliu,
- [Description("嘉里大通")]
- jialidatong,
- [Description("晋越快递")]
- jykd,
- [Description("快捷速递")]
- kuaijiesudi,
- [Description("联邦快递(国内)")]
- lianb,
- [Description("联昊通物流")]
- lianhaowuliu,
- [Description("龙邦物流")]
- longbanwuliu,
- [Description("立即送")]
- lijisong,
- [Description("乐捷递")]
- lejiedi,
- [Description("民航快递")]
- minghangkuaidi,
- [Description("美国快递")]
- meiguokuaidi,
- [Description("门对门")]
- menduimen,
- [Description("OCS")]
- ocs,
- [Description("配思货运")]
- peisihuoyunkuaidi,
- [Description("全晨快递")]
- quanchenkuaidi,
- [Description("全峰快递")]
- quanfengkuaidi,
- [Description("全际通物流")]
- quanjitong,
- [Description("全日通快递")]
- quanritongkuaidi,
- [Description("全一快递")]
- quanyikuaidi,
- [Description("如风达")]
- rufengda,
- [Description("三态速递")]
- santaisudi,
- [Description("盛辉物流")]
- shenghuiwuliu,
- [Description("申通")]
- shentong,
- [Description("顺丰")]
- shunfeng,
- [Description("速尔物流")]
- sue,
- [Description("盛丰物流")]
- shengfeng,
- [Description("赛澳递")]
- saiaodi,
- [Description("天地华宇")]
- tiandihuayu,
- [Description("天天快递")]
- tiantian,
- [Description("tnt")]
- tnt,
- [Description("ups")]
- ups,
- [Description("万家物流")]
- wanjiawuliu,
- [Description("文捷航空速递")]
- wenjiesudi,
- [Description("伍圆")]
- wuyuan,
- [Description("万象物流")]
- wxwl,
- [Description("新邦物流")]
- xinbangwuliu,
- [Description("信丰物流")]
- xinfengwuliu,
- [Description("亚风速递")]
- yafengsudi,
- [Description("一邦速递")]
- yibangwuliu,
- [Description("优速物流")]
- youshuwuliu,
- [Description("邮政包裹挂号信")]
- youzhengguonei,
- [Description("邮政国际包裹挂号信")]
- youzhengguoji,
- [Description("远成物流")]
- yuanchengwuliu,
- [Description("圆通速递")]
- yuantong,
- [Description("源伟丰快递")]
- yuanweifeng,
- [Description("元智捷诚快递")]
- yuanzhijiecheng,
- [Description("韵达快运")]
- yunda,
- [Description("运通快递")]
- yuntongkuaidi,
- [Description("越丰物流")]
- yuefengwuliu,
- [Description("源安达")]
- yad,
- [Description("银捷速递")]
- yinjiesudi,
- [Description("宅急送")]
- zhaijisong,
- [Description("中铁快运")]
- zhongtiekuaiyun,
- [Description("中通速递")]
- zhongtong,
- [Description("中邮物流")]
- zhongyouwuliu,
- [Description("忠信达")]
- zhongxinda,
- [Description("芝麻开门")]
- zhimakaimen
- }
- }
|