前段时间一直使用“车票无忧”在抢票(最开始觉得蛮好用,而且没什么时间,就先用着了。)

不管免费版还是收费版问题如下:

1)不支针对同一批列车按席别优先级进行买票。(比如有卧铺买卧铺,没有卧铺买硬座,硬座也没有买软卧,在没有就买站票)

2)不支持对同一批列车按时间优先级进行买票。(比如先买2月5号,没有买2月4日,再没有卖2月3日)

PS:因为买到一张不想要的票,但是又过了放票时间,所以开着“车票无忧”打断捡漏,发现不符合个人需求。

  所以打算最近抽出点时间来自己做一个自己的“火车票不发愁”工具,(*^__^*) 嘻嘻……

遇到问题:

1)The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

  在request = WebRequest.Create(url) as HttpWebRequest;之前加入:

  ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);

  private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
        {
            return true; //总是接受 
        }

2)Post过去没有返回登录错误

  跟踪报文发现包头不对,加入如下包头后正常:

      request.Headers.Add("Pragma", "no-cache");
          request.Headers.Add("Cache-Control", "no-cache");
          request.Headers.Add("X-Requested-With", "XMLHttpRequest");

第一步:构建HttpHelper

HttpHelper

  1 using System;
  2 using System.Collections.Generic;
  3 using System.IO;
  4 using System.Linq;
  5 using System.Net;
  6 using System.Net.Security;
  7 using System.Security.Cryptography.X509Certificates;
  8 using System.Text;
  9 using System.Threading.Tasks;
 10
 11 namespace WindowsFormsApplication1
 12 {
 13     public class HttpHelper
 14     {
 15         private static readonly string DefaultUserAgent = "Mozilla/6.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120131 Firefox/14.0";
 16         /// <summary>
 17         /// 创建GET方式的HTTP请求
 18         /// </summary>
 19         /// <param name="url">请求的URL</param>
 20         /// <param name="timeout">请求的超时时间</param>
 21         /// <param name="userAgent">请求的客户端浏览器信息,可以为空</param>
 22         /// <param name="cookies">随同HTTP请求发送的Cookie信息,如果不需要身份验证可以为空</param>
 23         /// <returns></returns>
 24         public static HttpWebResponse CreateGetHttpResponse(string url, int? timeout, string userAgent, CookieCollection cookies, string Referer = "")
 25         {
 26             if (string.IsNullOrEmpty(url))
 27             {
 28                 throw new ArgumentNullException("url");
 29             }
 30
 31             HttpWebRequest request;
 32             if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
 33             {
 34                 ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
 35                 request = WebRequest.Create(url) as HttpWebRequest;
 36                 request.ProtocolVersion = HttpVersion.Version10;
 37             }
 38             else
 39             {
 40                 request = WebRequest.Create(url) as HttpWebRequest;
 41             }
 42             request.Method = "GET";
 43             request.Referer = Referer;
 44             request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
 45             request.ContentType = "application/x-www-form-urlencoded";
 46
 47             request.UserAgent = DefaultUserAgent;
 48             if (!string.IsNullOrEmpty(userAgent))
 49             {
 50                 request.UserAgent = userAgent;
 51             }
 52             if (timeout.HasValue)
 53             {
 54                 request.Timeout = timeout.Value;
 55             }
 56             if (cookies != null)
 57             {
 58                 request.CookieContainer = new CookieContainer();
 59                 request.CookieContainer.Add(cookies);
 60             }
 61             return request.GetResponse() as HttpWebResponse;
 62         }
 63         /// <summary>
 64         /// 创建POST方式的HTTP请求
 65         /// </summary>
 66         /// <param name="url">请求的URL</param>
 67         /// <param name="parameters">随同请求POST的参数名称及参数值字典</param>
 68         /// <param name="timeout">请求的超时时间</param>
 69         /// <param name="userAgent">请求的客户端浏览器信息,可以为空</param>
 70         /// <param name="requestEncoding">发送HTTP请求时所用的编码</param>
 71         /// <param name="cookies">随同HTTP请求发送的Cookie信息,如果不需要身份验证可以为空</param>
 72         /// <returns></returns>
 73         public static HttpWebResponse CreatePostHttpResponse(string url, IDictionary<string, string> parameters, int? timeout, string userAgent, Encoding requestEncoding, CookieCollection cookies, string Referer)
 74         {
 75             if (string.IsNullOrEmpty(url))
 76             {
 77                 throw new ArgumentNullException("url");
 78             }
 79             if (requestEncoding == null)
 80             {
 81                 throw new ArgumentNullException("requestEncoding");
 82             }
 83             HttpWebRequest request = null;
 84             //如果是发送HTTPS请求
 85             if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
 86             {
 87                 ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
 88                 request = WebRequest.Create(url) as HttpWebRequest;
 89                 request.ProtocolVersion = HttpVersion.Version10;
 90             }
 91             else
 92             {
 93                 request = WebRequest.Create(url) as HttpWebRequest;
 94             }
 95             request.Method = "POST";
 96             request.Headers.Add("Accept-Language", "zh-CN,en-GB;q=0.5");
 97
 98             if (cookies != null)
 99             {
100                 request.CookieContainer = new CookieContainer();
101                 request.CookieContainer.Add(cookies);
102             }
103
104             request.Headers.Add("Pragma", "no-cache");
105             request.Headers.Add("Cache-Control", "no-cache");
106             request.Headers.Add("X-Requested-With", "XMLHttpRequest");
107             request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
108             request.ContentType = "application/x-www-form-urlencoded";
109             request.Referer = Referer;
110
111             if (!string.IsNullOrEmpty(userAgent))
112             {
113                 request.UserAgent = userAgent;
114             }
115             else
116             {
117                 request.UserAgent = DefaultUserAgent;
118             }
119
120             if (timeout.HasValue)
121             {
122                 request.Timeout = timeout.Value;
123             }
124
125             request.Expect = string.Empty;
126
127             //如果需要POST数据
128             if (!(parameters == null || parameters.Count == 0))
129             {
130                 StringBuilder buffer = new StringBuilder();
131                 int i = 0;
132                 foreach (string key in parameters.Keys)
133                 {
134                     if (i > 0)
135                     {
136                         buffer.AppendFormat("&{0}={1}", key, parameters[key]);
137                     }
138                     else
139                     {
140                         buffer.AppendFormat("{0}={1}", key, parameters[key]);
141                     }
142                     i++;
143                 }
144                 byte[] data = requestEncoding.GetBytes(buffer.ToString());
145                 using (Stream stream = request.GetRequestStream())
146                 {
147                     stream.Write(data, 0, data.Length);
148                 }
149             }
150             return request.GetResponse() as HttpWebResponse;
151         }
152
153         private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
154         {
155             return true; //总是接受
156         }
157     }
158 }

第二步:登录首页,获取Cookie

登录首页,获取Cookie

 1         private const string UrlMainPage = "https://dynamic.12306.cn/otsweb/main.jsp";
 2
 3      /// <summary>
 4         /// 登录首页,获取Cookie
 5         /// </summary>
 6         /// <param name="userAgent"></param>
 7         /// <param name="cookie"></param>
 8         public static void GetMainPage(int? timeout = null, string userAgent = null, CookieCollection cookie = null)
 9         {
10             var response = HttpHelper.CreateGetHttpResponse(UrlMainPage, timeout, userAgent, cookie ?? Cookies, "");
11
12             cookies.Add(response.Cookies);
13         }

第三步:获取登录验证码

获取登录验证码

 1         private const string UrlLoginImage = "http://dynamic.12306.cn/otsweb/passCodeAction.do?rand=sjrand";
 2
 3         /// <summary>
 4         /// 获取登录图片
 5         /// </summary>
 6         /// <param name="userAgent"></param>
 7         /// <param name="cookie"></param>
 8         /// <returns></returns>
 9         public static Bitmap GetLoginImage(int? timeout = null, string userAgent = null, CookieCollection cookie = null)
10         {
11             try
12             {
13                 var response = HttpHelper.CreateGetHttpResponse(UrlLoginImage, timeout, userAgent, cookie ?? Cookies);
14                 Stream resStream = response.GetResponseStream();//得到验证码数据流
15                 return new Bitmap(resStream);//初始化Bitmap图片
16             }
17             catch (Exception)
18             {
19                 return null;
20             }
21         }

第四步:登录

12306的登录分两步

1)登录http://dynamic.12306.cn/otsweb/loginAction.do?method=loginAysnSuggest页面,获取登录随机码

  返回Json格式(例如:{"loginRand":"421","randError":"Y"})。

2)将信息Post到http://dynamic.12306.cn/otsweb/loginAction.do?method=login进行登录

为方便解析Json,使用最近在研究的IronJs解析Json。

登录

 1         private const string UrlLoginStep1 = "http://dynamic.12306.cn/otsweb/loginAction.do?method=loginAysnSuggest";
 2         private const string UrlLoginStep2 = "http://dynamic.12306.cn/otsweb/loginAction.do?method=login";
 3
 4    /// <summary>
 5         /// 登录
 6         /// </summary>
 7         /// <param name="userName"></param>
 8         /// <param name="pass"></param>
 9         /// <param name="verificationCode"></param>
10         /// <param name="timeout"></param>
11         /// <param name="userAgent"></param>
12         /// <param name="cookie"></param>
13         /// <returns></returns>
14         public static LoginResponse Login(string userName, string pass, string verificationCode
15             , int? timeout = null, string userAgent = null, CookieCollection cookie = null)
16         {
17             //   获取登录随机验证码loginRand
18             string str = "";
19             var response = HttpHelper.CreateGetHttpResponse(UrlLoginStep1, timeout, userAgent, cookie ?? Cookies, "http://dynamic.12306.cn/otsweb/loginAction.do?method=init");
20             cookies.Add(response.Cookies);
21
22             try
23             {
24                 using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
25                 {
26                     str = reader.ReadToEnd();
27                 }
28
29                 if (str.Length > 50)
30                 {
31                     return new LoginResponse() { IsLogined = false, Message = "网络异常,请稍后重试。", type = ErrorType.NetworkError };
32                 }
33             }
34             catch (Exception)
35             {
36                 return new LoginResponse() { IsLogined = false, Message = "网络可能存在问题,请您重试一下!", type = ErrorType.NetworkError };
37             }
38
39             // 解析第一次返回值,获取登录随机验证码loginRand,执行登录
40             var v = new IronJS.Hosting.CSharp.Context();
41             string strJson = "var json = " + str;
42             dynamic dy = v.Execute(strJson);
43
44             Dictionary<string, string> dic = new Dictionary<string, string>();
45             dic.Add("loginUser.user_name", userName);
46             dic.Add("nameErrorFocus", "");
47             dic.Add("user.password", pass);
48             dic.Add("passwordErrorFocus", "");
49             dic.Add("randCode", verificationCode);
50             dic.Add("randErrorFocus", "");
51             dic.Add("loginRand", dy.loginRand);
52             response = HttpHelper.CreatePostHttpResponse(UrlLoginStep2, dic, timeout, userAgent, Encoding.UTF8, cookie ?? Cookies, "http://dynamic.12306.cn/otsweb/loginAction.do?method=init");
53
54             cookies.Add(response.Cookies);
55
56             try
57             {
58                 using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
59                 {
60                     str = reader.ReadToEnd();
61                 }
62             }
63             catch (Exception)
64             {
65                 return new LoginResponse() { IsLogined = false, Message = "网络可能存在问题,请您重试一下!", type = ErrorType.NetworkError };
66             }
67
68             Regex logined = new Regex(@"'[^']*? ,您好!'");
69
70             Regex networkError = new Regex(@"网络可能存在问题,请您重试一下");
71
72             Regex verificationError = new Regex(@"请输入正确的验证码");
73
74             Regex PasswordError = new Regex(@"密码输入错误");
75
76             if (logined.IsMatch(str))
77             {
78                 return new LoginResponse() { IsLogined = true, Message = "", type = ErrorType.None, LoginName = logined.Matches(str)[0].Value };
79             }
80             else if (verificationError.IsMatch(str))
81             {
82                 return new LoginResponse() { IsLogined = false, Message = "请输入正确的验证码!", type = ErrorType.NetworkError };
83             }
84             else if (networkError.IsMatch(str))
85             {
86                 return new LoginResponse() { IsLogined = false, Message = "网络可能存在问题,请您重试一下!", type = ErrorType.NetworkError };
87             }
88             else if (PasswordError.IsMatch(str))
89             {
90                 return new LoginResponse() { IsLogined = false, Message = "密码错误!", type = ErrorType.PassordError };
91             }
92
93             return new LoginResponse() { IsLogined = false, Message = "未知错误!", type = ErrorType.OtherError };
94         }

实体类&枚举

1 class LoginResponse 2 { 3 public bool IsLogined; 4 public string Message; 5 public string LoginName; 6 public ErrorType type; 7 } 8 9 public enum ErrorType 10 { 11 None, 12 NetworkError, 13 VerificationError, 14 PassordError, 15 OtherError 16 }

第五步:获取常用联系人

获取常用联系人

 1         private const string UrlFavoriteContacts = "http://dynamic.12306.cn/otsweb/passengerAction.do?method=getPagePassengerAll";
 2
 3 /// <summary>
 4         /// 获取常用联系人
 5         /// </summary>
 6         /// <param name="timeout"></param>
 7         /// <param name="userAgent"></param>
 8         /// <param name="cookie"></param>
 9         public static List<Contact> GetFavoriteContacts(int pageIndex, int pageSize, out int count, int? timeout = null, string userAgent = null,
10                                                CookieCollection cookie = null)
11         {
12             List<Contact> contacts = new List<Contact>();
13             count = 0;
14             Dictionary<string, string> dic = new Dictionary<string, string>();
15             dic.Add("pageIndex", pageIndex.ToString());
16             dic.Add("pageSize", pageSize.ToString());
17             dic.Add("passenger_name", "请输入汉字或拼音首字母");
18             var response = HttpHelper.CreatePostHttpResponse(UrlFavoriteContacts, dic, timeout, userAgent, Encoding.UTF8, cookie ?? Cookies, "https://dynamic.12306.cn/otsweb/passengerAction.do?method=initUsualPassenger12306");
19
20             cookies.Add(response.Cookies);
21             dynamic dy;
22             try
23             {
24                 using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
25                 {
26                     var str = reader.ReadToEnd();
27
28                     var v = new IronJS.Hosting.CSharp.Context();
29                     string strJson = "var json = " + str;
30
31                     dy = v.Execute(strJson);
32
33                     count = (int)dy.recordCount;
34
35                     for (int i = 0; i < dy.rows.length; i++)
36                     {
37                         contacts.Add(new Contact()
38                         {
39                             Name = dy.rows[i].passenger_name,
40                             IdTypeName = dy.rows[i].passenger_id_type_name,
41                             IdNo = dy.rows[i].passenger_id_no,
42                             IdTypeCode = dy.rows[i].passenger_id_type_code,
43                             Mobile = dy.rows[i].mobile_no,
44                             PassengerTypeName = dy.rows[i].passenger_type_name,
45                             PassengerType = dy.rows[i].passenger_type
46                         });
47                     }
48                 }
49             }
50             catch (Exception)
51             {
52
53             }
54
55             return contacts;
56         }

Winfrom页面调用:

为了偷偷懒,用了 Control.CheckForIllegalCrossThreadCalls = false;高手们直接忽略吧。。

WinFrom调用

 1 public partial class Form1 : Form
 2     {
 3         public Form1()
 4         {
 5             InitializeComponent();
 6
 7
 8             Control.CheckForIllegalCrossThreadCalls = false;
 9
10             System.Threading.ThreadPool.QueueUserWorkItem((m) =>
11             {
12                 _12306Class.GetMainPage(cookie: new CookieCollection());
13                 GetLoginImage();
14             });
15         }
16
17         private void GetLoginImage()
18         {
19             pictureBox1.Image = _12306Class.GetLoginImage();
20         }
21
22         private void button1_Click(object sender, EventArgs e)
23         {
24             System.Threading.ThreadPool.QueueUserWorkItem((m) =>
25                 {
26                     button1.Enabled = false;
27
28                     checkedListBox1.Items.Clear();
29
30                     var v = _12306Class.Login(textBox1.Text, textBox2.Text, textBox3.Text);
31                     if (v.IsLogined)
32                     {
33                         int count = 0;
34                         int pageSize = 7;
35                         int pageIndex = 0; ;
36                         do
37                         {
38                             List<Contact> contacts = _12306Class.GetFavoriteContacts(pageIndex, pageSize, out count);
39
40                             foreach (var contact in contacts)
41                             {
42                                 checkedListBox1.Items.Add(string.Format("{0}\t{1}\t{2}", contact.Name, contact.IdTypeName, contact.IdNo));
43                             }
44
45                         } while ((pageIndex + 1) * pageSize < count);
46                     }
47                     else
48                     {
49                         MessageBox.Show(v.Message);
50                         button1.Enabled = true;
51                     }
52                 });
53         }
54
55         private void button2_Click(object sender, EventArgs e)
56         {
57             GetLoginImage();
58         }
59
60
61     }

交互报文

main.jsp

 1 GET /otsweb/main.jsp HTTP/1.0
 2 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
 3 Content-Type: application/x-www-form-urlencoded
 4 User-Agent: Mozilla/6.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120131 Firefox/14.0
 5 Host: dynamic.12306.cn
 6 Connection: Keep-Alive
 7
 8
 9
10
11 ----------------------------------------------------------------
12
13
14
15 HTTP/1.1 200 OK
16 Date: Wed, 30 Jan 2013 09:26:23 GMT
17 Server: Apache-Coyote/1.1
18 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
19 Set-Cookie: JSESSIONID=DF8E17DA665A67ECD327B05D510EC3AA; Path=/otsweb
20 Content-Type: text/html;charset=UTF-8
21 Set-Cookie: BIGipServerotsweb=2513699082.36895.0000; path=/
22 X-Cache: MISS from cache.51cdn.com
23 X-Via: 1.1 swdx14:8361 (Cdn Cache Server V2.0)
24 Connection: close

passCodeAction.do

 1 GET /otsweb/passCodeAction.do?rand=sjrand HTTP/1.1
 2 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
 3 Content-Type: application/x-www-form-urlencoded
 4 User-Agent: Mozilla/6.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120131 Firefox/14.0
 5 Host: dynamic.12306.cn
 6 Cookie: JSESSIONID=DF8E17DA665A67ECD327B05D510EC3AA; BIGipServerotsweb=2513699082.36895.0000
 7
 8 ------------------------------------------------------------------------
 9
10 HTTP/1.1 200 OK
11 Date: Wed, 30 Jan 2013 09:26:27 GMT
12 Server: Apache-Coyote/1.1
13 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
14 Pragma: No-cache
15 Cache-Control: no-cache
16 Expires: Thu, 01 Jan 1970 00:00:00 GMT
17 Content-Type: image/jpeg
18 Transfer-Encoding: chunked
19 X-Cache: MISS from cache.51cdn.com
20 X-Via: 1.1 swdx15:8361 (Cdn Cache Server V2.0)
21 Connection: keep-alive
22
23 21
24 �PNG
25 

loginAction.do

 1 GET /otsweb/loginAction.do?method=loginAysnSuggest HTTP/1.1
 2 Referer: http://dynamic.12306.cn/otsweb/loginAction.do?method=init
 3 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
 4 Content-Type: application/x-www-form-urlencoded
 5 User-Agent: Mozilla/6.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120131 Firefox/14.0
 6 Host: dynamic.12306.cn
 7 Cookie: JSESSIONID=DF8E17DA665A67ECD327B05D510EC3AA; BIGipServerotsweb=2513699082.36895.0000
 8
 9
10
11 ---------------------------------------------------------------------
12
13
14 HTTP/1.1 200 OK
15 Date: Wed, 30 Jan 2013 09:26:33 GMT
16 Server: Apache-Coyote/1.1
17 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
18 Pragma: no-cache
19 Cache-Control: no-cache
20 Expires: Wed, 31 Dec 1969 23:59:59 GMT
21 Content-Type: text/html;charset=UTF-8
22 Content-Length: 35
23 X-Cache: MISS from cache.51cdn.com
24 X-Via: 1.1 swdx15:8361 (Cdn Cache Server V2.0)
25 Connection: keep-alive
26
27 {"loginRand":"896","randError":"Y"}

loginAction.do?method=login

 1 POST /otsweb/loginAction.do?method=login HTTP/1.1
 2 Accept-Language: zh-CN,en-GB;q=0.5
 3 Pragma: no-cache
 4 Cache-Control: no-cache
 5 X-Requested-With: XMLHttpRequest
 6 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
 7 Content-Type: application/x-www-form-urlencoded
 8 Referer: http://dynamic.12306.cn/otsweb/loginAction.do?method=init
 9 User-Agent: Mozilla/6.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120131 Firefox/14.0
10 Host: dynamic.12306.cn
11 Cookie: JSESSIONID=DF8E17DA665A67ECD327B05D510EC3AA; BIGipServerotsweb=2513699082.36895.0000
12 Content-Length: 142
13 Expect: 100-continue
14
15 loginUser.user_name=253180123@qq.com&nameErrorFocus=&user.password=12345678&passwordErrorFocus=&randCode=94ct&randErrorFocus=&loginRand=896
16
17
18
19 -----------------------------------------------------------------------------
20
21 HTTP/1.1 200 OK
22 Date: Wed, 30 Jan 2013 09:26:34 GMT
23 Server: Apache-Coyote/1.1
24 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
25 Pragma: no-cache
26 Cache-Control: no-cache
27 Expires: Wed, 31 Dec 1969 23:59:59 GMT
28 Content-Type: text/html;charset=UTF-8
29 Transfer-Encoding: chunked
30 X-Cache: MISS from cache.51cdn.com
31 X-Via: 1.1 swdx15:8361 (Cdn Cache Server V2.0)
32 Connection: keep-alive
33
34 2000

passengerAction.do?method=getPagePassengerAll

 1 POST /otsweb/passengerAction.do?method=getPagePassengerAll HTTP/1.1
 2 Accept-Language: zh-CN,en-GB;q=0.5
 3 Pragma: no-cache
 4 Cache-Control: no-cache
 5 X-Requested-With: XMLHttpRequest
 6 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
 7 Content-Type: application/x-www-form-urlencoded
 8 Referer: https://dynamic.12306.cn/otsweb/passengerAction.do?method=initUsualPassenger12306
 9 User-Agent: Mozilla/6.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120131 Firefox/14.0
10 Host: dynamic.12306.cn
11 Cookie: JSESSIONID=DF8E17DA665A67ECD327B05D510EC3AA; BIGipServerotsweb=2513699082.36895.0000
12 Content-Length: 71
13 Expect: 100-continue
14
15 pageIndex=0&pageSize=7&passenger_name=请输入汉字或拼音首字母
16
17
18
19 -----------------------------------------------------------------------------------
20
21
22
23 HTTP/1.1 200 OK
24 Date: Wed, 30 Jan 2013 09:26:35 GMT
25 Server: Apache-Coyote/1.1
26 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
27 Pragma: no-cache
28 Cache-Control: no-cache
29 Expires: Wed, 31 Dec 1969 23:59:59 GMT
30 Content-Type: text/html;charset=UTF-8
31 Content-Length: 1329
32 X-Cache: MISS from cache.51cdn.com
33 X-Via: 1.1 swdx15:8361 (Cdn Cache Server V2.0)
34 Connection: keep-alive
35
36 {"recordCount":2,"rows":[{"address":"","born_date":{"date":25,"day":0,"hours":13,"minutes":39,"month":10,"seconds":36,"time":1353821976686,"timezoneOffset":-480,"year":112},"code":"1","country_code":"","email":"","first_letter":"","isUserSelf":"N","mobile_no":"12345678901","old_passenger_id_no":"","old_passenger_id_type_code":"","old_passenger_name":"","passenger_flag":"0","passenger_id_no":"123456789012345678","passenger_id_type_code":"1","passenger_id_type_name":"二代身份证","passenger_name":"XX","passenger_type":"1","passenger_type_name":"成人","phone_no":"","postalcode":"","recordCount":"2","sex_code":"","sex_name":"","studentInfo":null},{"address":"","born_date":{"date":20,"day":3,"hours":0,"minutes":0,"month":5,"seconds":0,"time":645807600000,"timezoneOffset":-540,"year":90},"code":"2","country_code":"CN","email":"253180123@qq.com","first_letter":"COSMOKEY","isUserSelf":"Y","mobile_no":"12345678901","old_passenger_id_no":"","old_passenger_id_type_code":"","old_passenger_name":"","passenger_flag":"0","passenger_id_no":"123456789012345678","passenger_id_type_code":"1","passenger_id_type_name":"二代身份证","passenger_name":"XXX","passenger_type":"1","passenger_type_name":"成人","phone_no":"","postalcode":"","recordCount":"2","sex_code":"M","sex_name":"男","studentInfo":null}]}

截图:

Demo下载

转载于:https://www.cnblogs.com/comsokey/archive/2013/01/30/12306Task.html

马后炮之12306抢票工具(一) -- 登录相关推荐

  1. 马后炮之12306抢票工具(二) -- 联系人获取车次

    续马后炮之12306抢票工具(一) -- 登录 今天完成模块: 添加常用联系人 获取车站列表 获取车次信息 获取常用联系人已经在马后炮之12306抢票工具(一) -- 登录中介绍,不在重复 遇到问题: ...

  2. 马后炮之12306抢票工具(四)--抢票Demo,2014年1月9日终结版

    时隔一年多,终于朋友的忽悠下吧抢票Demo的最后一步完善了,与2014年1月9日成功生成车票. Demo仅经过自己测试,并未在高峰期进行测试,代码质量很差,因为赶工,套用去年模板并未使用设计模式. 代 ...

  3. 易达火车票之12306抢票工具——预览

    缘由:这段时间抢票居然颗粒无收,一方面是由于12306系统很烂,另一方面是公司网速真的慢,还有都是热门路线,抢了几天居然都没有成功,也用过网络上的一些抢票工具,好用的极少,于是萌发了一个想法,就是自己 ...

  4. 12306抢票系统(登录功能---二维码+账号密码)

    文章目录 一.二维码登录方式 二.账号密码登录方式 超级鹰第三方库 账号密码登录 代码汇总: 一.二维码登录方式 二维码登录方式:用户手机端扫描网页二维码登录,比账号密码登录更简易 话不多说,先上代码 ...

  5. 12306抢票系统(框架+代码)- 持续更新

    文章目录 一.框架展示(后续将提供源码) 二.界面展示 三.过程及结果展示 12306抢票系统(登录功能-二维码+账号密码)---------- 点击跳转 一.框架展示(后续将提供源码)    首先在 ...

  6. 分享12306抢票心得-终极秒杀思路篇

    12306抢票的关键拼的就是整点出票的速度,快的几秒钟,慢的几分钟,本文提供终极抢票攻略,通过多线程扫描上万个CDN,来大幅度提升出票速度. 准备一:需要了解CDN和切站的机制,请参考: 分享1230 ...

  7. python编程实践(3):python+selenium实现12306抢票脚本

    又到了一年一度的春运时节,抢个票? 1.设计思路 如果我们要买一张火车票,我们会怎么做?打开12306,登陆,输入出发地和目的地,选择出行日期,然后点击查询,有余票的话就下单购买,没有票就点刷新或者等 ...

  8. python写一个简单的12306抢票

    引言 每逢过年就到了12306抢票高峰期,自己总想研究一下12306购票的流程,虽然网上已经很多资料,但是总比不过自己的亲身体会,于是便琢磨着写一个抢票软件,本人比较熟悉python,所以软件是用py ...

  9. 四、基于HTTPS协议的12306抢票软件设计与实现--水平DNS并发查询分享

    一.基于HTTPS协议的12306抢票软件设计与实现--实现效果  二.基于HTTPS协议的12306抢票软件设计与实现--相关接口以及数据格式 三.基于HTTPS协议的12306抢票软件设计与实现- ...

最新文章

  1. ARM:钒和铁替代固氮酶的前世今生
  2. 基于JDK 1.8 的 Java 容器UML图
  3. python 透视变换补边
  4. delphi的ArrayList
  5. Docker资源限制
  6. Linux中用户的简介与管理
  7. 从Oracle到PostgreSQL:动态性能视图 vs 标准统计视图
  8. Jenkins动态部署方案
  9. 和菜鸟一起学android4.0.3源码之lcd屏幕背光调节
  10. 苹果个人开发者账号如何升级成公司账号
  11. 易语言单窗口单ip软件源码_梦幻西游怎样多开ip转金?老玩家的十大转金秘籍奉上...
  12. localhost 127.0.0.1 本机IP
  13. virtualbox 给linux共享文件夹
  14. hmcl启动器java下载_HMCL启动器
  15. cesium获取模型实时坐标_cesium获取坐标及高程
  16. 一些名片上最常用的中英文称呼:
  17. GBase 8c核心技术简介
  18. C语言---移盘子----Hanoi(汉诺)塔问题,显示移动盘子的步骤
  19. PHP学习——输出学生名单
  20. Chrome OS 与 Android 的生死爱欲

热门文章

  1. 安装abuntu时候联想拯救者R7000P怎么进入bios
  2. 【C语言】VS编辑器实用的调试技巧
  3. 天地图标注获取与修改并保存信息
  4. TennisWorld
  5. Java设计模式--在项目中的应用
  6. 【C语言】深入浅出理解指针及内存与指针的关系(详细讲解+代码展示)
  7. yarn 安装vue
  8. 网页设计作业 开心网旅游(11页) web前端期末大作业 html+css+javascript网页设计实例
  9. 2023最新SSM计算机毕业设计选题大全(附源码+LW)之java康复系统4y703
  10. html如何使文本变为粗体_如何使组框的文本变为粗体而不是其中包含的控件的文本?...