private List<Cinema> GetCinemas(SubArea subArea,City city) { List<Cinema> cinemas = new List<Cinema>(); string url = subArea.Url; while (url!=null&&url!="") { string html = Utility.Helper.WebHelper.Get(url,null,null,null,GetMeituanCookies("")); List<string> cinemaHtmls = Utility.Helper.HtmlHelper.ListOuterHtmlMatchXpath(html, "//h4[contains(@class,'J-cinema-label')]/a"); foreach (var cinemaHtml in cinemaHtmls) { if (cinemaHtml.Contains("全部") || cinemaHtml.Contains("其它")) continue; cinemas.Add(new Cinema() { City = city, Name = Utility.Helper.HtmlHelper.InnerText(cinemaHtml), SubAreaName = subArea.Name, Url = Utility.Helper.HtmlHelper.AttributeMatchXpath(cinemaHtml, "//a", "href") }); } url = GetNextPageUrl(html, city.Url); } return cinemas; }
private List<SubArea> GetSubAreas(string url) { List<SubArea> subAreas = new List<SubArea>(); if (!url.EndsWith("/")) url = url + "/dianying/cinemalist"; else url = url + "dianying/cinemalist"; string html = Utility.Helper.WebHelper.Get(url,null,null,null,GetMeituanCookies(url)); List<string> subAreaHtmls = Utility.Helper.HtmlHelper.ListOuterHtmlMatchXpath(html, "//div[contains(@class,'filter-label-list')][1]//ul/li/a"); foreach(var subAreaHtml in subAreaHtmls) { SubArea sa = new SubArea(); sa.Name = Utility.Helper.HtmlHelper.InnerText(subAreaHtml).Trim(); sa.Url = Utility.Helper.HtmlHelper.AttributeMatchXpath(subAreaHtml, "//a", "href"); if (sa.Url.Contains("subway")) continue; if (sa.Name.Contains("全部")||sa.Name.Contains("其它")) continue; subAreas.Add(sa); } return subAreas; }