public async Task GivenHtmlContent_DoesNotReturnEmptyList() { var client = new Mock<IHttpClientWrapper>(); client.Setup(x => x.GetStringAsync(It.IsAny<Uri>())).ReturnsAsync(FirstPageHtml); var scraper = new ListingPageScraper(client.Object, new Uri("http://www.wegottickets.com/searchresults/region/0/latest")); var result = await scraper.Scrape(); Assert.That(result.Uris, Is.Not.Empty); }
public async Task GivenHtmlContent_ReturnsNextPageUri() { var client = new Mock<IHttpClientWrapper>(); client.Setup(x => x.GetStringAsync(It.IsAny<Uri>())).ReturnsAsync(FirstPageHtml); var scraper = new ListingPageScraper(client.Object, new Uri("http://www.wegottickets.com/searchresults/region/0/latest")); var result = await scraper.Scrape(); Assert.That(result.NextPage.ToString(), Is.EqualTo("http://www.wegottickets.com/searchresults/page/2/latest")); }
static async Task Scrape() { Console.Out.WriteLine("Starting..."); var client = new HttpClientWrapper(); var scraper = new ListingPageScraper(client, new Uri("http://www.wegottickets.com/searchresults/page/0/latest")); ListingPage concertListings = await scraper.Scrape(); foreach (var listing in concertListings.Uris) { var concertPageScraper = new ConcertPageScraper(client, listing); var concert = await concertPageScraper.Scrape(); Console.Out.WriteLine($"{concert.Artist} playing at {concert.City} {concert.Venue}, on {concert.Date}. Tickets for {concert.Price}."); } return; }
static async Task Scrape() { Console.Out.WriteLine("Starting..."); var client = new HttpClientWrapper(); var scraper = new ListingPageScraper(client, new Uri("http://www.wegottickets.com/searchresults/page/0/latest")); ListingPage concertListings = await scraper.Scrape(); foreach (var listing in concertListings.Uris) { var concertPageScraper = new ConcertPageScraper(client, listing); var concert = await concertPageScraper.Scrape(); Console.Out.WriteLine($"{concert.Artist} playing at {concert.City} {concert.Venue}, on {concert.Date}. Tickets for {concert.Price}."); } return; }