zoukankan      html  css  js  c++  java
  • 马后炮之12306抢票工具(一) 登录

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

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

    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下载

  • 相关阅读:
    ios动态创建类Class
    iOS 视图控制器转场详解
    HTML5新增标签属性
    HTML5入门篇
    ExtJs 添加员工 实例 ---- 锚点布局 anchor 可自动伸缩
    Ext 初级UI设计
    Ext 面向对象程序设计 入门篇
    改善EF代码的方法(下)
    改善EF代码的方法(上)
    EF 存储过程(下)
  • 原文地址:https://www.cnblogs.com/comsokey/p/12306Task.html
Copyright © 2011-2022 走看看