private void GetVenueInformation(IDocument document, CrawledInfo crawledInfo) { // navigate down to the classes we want IHtmlCollection <IElement> elements = document.GetElementsByClassName("eventinfo"); var element = elements.Where(e => e.Children.HasClass("g-ui-box-content")).First(); var childElement = element.FirstElementChild; foreach (IElement child in childElement.Children) { if (child.TagName == "H3") { GetCityAndVenue(crawledInfo, child.FirstElementChild.GetAttribute("title")); } else if (child.TagName == "P" && child.ClassName == null) { crawledInfo.EventDate = this.dateTimeExtracter.Extract(child.FirstElementChild.Text()); } } }
private async Task GetEventInfo(IBrowsingContext context, string actTitle, string eventAddress) { var document = await OpenPage(context, eventAddress); var crawledInfo = new CrawledInfo(); crawledInfo.ArtistName = actTitle; try { GetVenueInformation(document, crawledInfo); this.data.Add(crawledInfo); Console.WriteLine(string.Format("Fetched data {0}", this.data.Count)); } catch (Exception e) { // couldn't get required details Console.WriteLine(string.Format("Failed to crawl {0} details at: {1}", actTitle, eventAddress)); } }
private void GetCityAndVenue(CrawledInfo crawledInfo, string venueLocation) { string[] array = venueLocation.Split(","); crawledInfo.VenueName = array[0].Trim(); crawledInfo.CityName = array[1].Trim(); }