bool InitQueryInfo(QueryParam query) { if (_queryInfo != null) { return(true); } if (_queryInfo == null || _queryInfo.QueryFlag != query.Resign) { lock (this) { if (_queryInfo == null || _queryInfo.QueryFlag != query.Resign) { HttpContext <string> contextHtmlContext; contextHtmlContext = _client.RunRequestLoop(_ => _client.Create <string>(HttpMethod.Get, "http://www.12306.cn/opn/leftTicket/init", "http://www.12306.cn/opn/login/init")); if (!contextHtmlContext.IsValid()) { return(false); } var html = contextHtmlContext.Result; var matches = ParseUtility.Matches(@"(CLeftTicketUrl|isSaveQueryLog)\s*=\s*['""]([^'""]+)['""]", html).ToArray(); var saveQueryLog = matches.Where(s => s.Success && s.Groups[1].Value.IsIgnoreCaseEqualTo("isSaveQueryLog")).Select(s => s.Groups[2].Value).FirstOrDefault() == "Y"; var queryUrl = matches.Where(s => s.Success && s.Groups[1].Value.IsIgnoreCaseEqualTo("CLeftTicketUrl")).Select(s => s.Groups[2].Value).FirstOrDefault(); if (string.IsNullOrEmpty(queryUrl)) { return(false); } _queryInfo = new TicketQueryRequestParamInfo() { EnableSaveLog = saveQueryLog, LastSaveLogTime = DateTime.MinValue, QueryFlag = query.Resign, Url = "http://www.12306.cn/opn/" + queryUrl }; } } } return(_queryInfo != null); }