查快递--快递100 抓包

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace ExpressCheck
{
public partial class Form1 : Form
{
private SynchronizationContext Context;
public Form1()
{
InitializeComponent();
Context = SynchronizationContext.Current;

}

private void button1_Click(object sender, EventArgs e)
{
new System.Threading.Thread(QueryExpress).Start(textBox1.Text);
}

private void QueryExpress(object obj)
{
try
{
HttpCodeLib.Wininet w = new HttpCodeLib.Wininet();
string retCode = w.GetData(string.Format("http://www.kuaidi100.com/autonumber/auto?num={0}", obj));
List<ExpressType> typeList = JsonConvert.DeserializeObject<List<ExpressType>>(retCode);
ExpressInfo info;
foreach (ExpressType item in typeList)
{
retCode = w.GetUtf8(string.Format("http://www.kuaidi100.com/query?type={0}&postid={1}", item.ComCode, obj));
info = JsonConvert.DeserializeObject<ExpressInfo>(retCode);
if (info != null && info.Status == "200")
{
OnLog("当前订单查询成功:");
foreach (Datum tmp in info.Data)
{
OnLog("【" + tmp.Time + "】 " + tmp.Context);
}
break;
}
}
}
catch (Exception ex)
{
OnLog(ex.Message);
}
}

private void OnLog(string log)
{
Context.Send(o =>
{
textBox2.Text += log + "\r\n";
}, null);
}
}

public class ExpressType
{
[JsonProperty("comCode")]
public string ComCode { get; set; }

[JsonProperty("id")]
public string Id { get; set; }

[JsonProperty("noCount")]
public int NoCount { get; set; }

[JsonProperty("noPre")]
public string NoPre { get; set; }

[JsonProperty("startTime")]
public string StartTime { get; set; }
}

public class ExpressInfo
{
[JsonProperty("nu")]
public string Nu { get; set; }

[JsonProperty("message")]
public string Message { get; set; }

[JsonProperty("ischeck")]
public string Ischeck { get; set; }

[JsonProperty("com")]
public string Com { get; set; }

[JsonProperty("updatetime")]
public string Updatetime { get; set; }

[JsonProperty("status")]
public string Status { get; set; }

[JsonProperty("condition")]
public string Condition { get; set; }

[JsonProperty("data")]
public Datum[] Data { get; set; }

[JsonProperty("state")]
public string State { get; set; }
}

public class Datum
{
[JsonProperty("time")]
public string Time { get; set; }

[JsonProperty("context")]
public string Context { get; set; }

[JsonProperty("ftime")]
public string Ftime { get; set; }
}
}

posted @ 2016-11-30 17:00  qizhuocai  阅读(264)  评论(0编辑  收藏  举报