public void Get() { string url = "https://mobile.eventshopper.com/mobilewroom/?wr=07a73b4d-6e15-4926-8f53-abe29a7834ea&preFill=1&lang=en&locale=en_us&eventid=278555&ec=STC151106&src=AEGAXS1_WMAIN&skin=axs_staples&fbShareURL=m.axs.com%2Fevents%2F278555%2Fnitro-circus-live-tickets%3F%26ref%3Devs_fb"; string wr = "07a73b4d-6e15-4926-8f53-abe29a7834ea"; HttpSimulator simulator = new HttpSimulator(); string respose = simulator.Get(url); string lot = simulator.GetData(respose, "var lotId = \"", "\";", System.Text.RegularExpressions.RegexOptions.None); string xmlData = string.Format("<?xml version=\"1.0\"?><methodCall><methodName>getPhase</methodName><params><param><value><string>{0}</string></value></param><param><value><string>{1}</string></value></param></params></methodCall>", wr, lot); string xmlResponse = simulator.PostFormUrlEncoded(string.Format("https://tickets.axs.com/xmlrpc/?methodName=getPhase&lotId={0}&wr={1}", lot, wr), xmlData); string hash = GetXmlNodeValue(xmlResponse.Replace("<?xml version=\"1.0\"?>", string.Empty), "hash"); string ts = GetXmlNodeValue(xmlResponse.Replace("<?xml version=\"1.0\"?>", string.Empty), "hashts"); string newUrl = string.Format("{0}&lot={1}&hash={2}&ts={3}", url.Replace("mobilewroom", "mobileshopper"), lot, hash, ts); simulator.Get(newUrl); string res = simulator.PostPlainText("https://mobile.eventshopper.com/mobileshopper/ajax/availWSS.json", string.Format("[\"{0}\"]", wr)); }
private bool AreTicketsAvailable(string url, string wr, out Dictionary<string, string> seatStatus) { HttpSimulator simulator = new HttpSimulator(); string respose = simulator.Get(url); bool isBlank = false; string lot = simulator.GetData(respose, "var lotId = \"", "\";", System.Text.RegularExpressions.RegexOptions.None); string xmlData = string.Format("<?xml version=\"1.0\"?><methodCall><methodName>getPhase</methodName><params><param><value><string>{0}</string></value></param><param><value><string>{1}</string></value></param></params></methodCall>", wr, lot); string xmlResponse = simulator.PostFormUrlEncoded(string.Format("https://tickets.axs.com/xmlrpc/?methodName=getPhase&lotId={0}&wr={1}", lot, wr), xmlData); string hash = GetXmlNodeValue(xmlResponse.Replace("<?xml version=\"1.0\"?>", string.Empty), "hash"); string ts = GetXmlNodeValue(xmlResponse.Replace("<?xml version=\"1.0\"?>", string.Empty), "hashts"); string newUrl = string.Format("{0}&lot={1}&hash={2}&ts={3}", url.Replace("mobilewroom", "mobileshopper"), lot, hash, ts); string mobileShopperResponse = simulator.Get(newUrl); string jsonResponse = simulator.PostPlainText("https://mobile.eventshopper.com/mobileshopper/ajax/availWSS.json", string.Format("[\"{0}\"]", wr)); isBlank = isEmpty(jsonResponse); if (!isBlank) { seatStatus = GetSeatStatus(simulator, jsonResponse, mobileShopperResponse, wr); } else { seatStatus = null; } return isBlank; }
public Dictionary<string, string> GetSeatStatus(HttpSimulator simulator, string json, string mobileShopperResponse, string wr) { Dictionary<string, string> seatAvailability = new Dictionary<string, string>(); string eventTypeCode = simulator.GetData(mobileShopperResponse, "eventTypeCode=\"", "\" eventCode=\"", System.Text.RegularExpressions.RegexOptions.None); string eventCode = simulator.GetData(mobileShopperResponse, "eventCode=\"", "\" eventDateTimeTimestamp=\"", System.Text.RegularExpressions.RegexOptions.None); string postSeatData = string.Format("wr={0}&eventTypeCode={1}&eventCode={2}&pack=&action=search", wr, eventTypeCode, eventCode); string seatResponse = simulator.PostFormUrlEncoded("https://mobile.eventshopper.com/mobileshopper/index.html", postSeatData); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(seatResponse); var goodJsonObj = JObject.Parse(json); foreach (var htmlNode in doc.DocumentNode.SelectNodes("//span[@class='price-level-range']")) { if (htmlNode.Attributes["price-level-code"] != null) { string price = htmlNode.SelectSingleNode("strong").InnerText; seatAvailability.Add(price, "NA"); } } int priceLevel = 0; foreach (JArray prop in goodJsonObj["eventavail"][eventCode]) { var nthKey = seatAvailability.Select((Val, Index) => new { Val, Index }) .Single(viPair => viPair.Index == priceLevel) .Val .Key; seatAvailability[nthKey] = Convert.ToString(prop[1]); priceLevel++; } return seatAvailability; }