private async Task <List <dynamic> > GetPageData(string CURRENT_URL, List <dynamic> results) { var config = Configuration.Default.WithDefaultLoader(); var context = BrowsingContext.New(config); var document = await context.OpenAsync(CURRENT_URL); // Debug //_logger.LogInformation(document.DocumentElement.OuterHtml); var shutrows = document.QuerySelectorAll("tr"); foreach (var row in shutrows) { // Create a container object CurrentShutdown shutdown = new CurrentShutdown() { Region = row.QuerySelector("tr td:nth-child(1)").TextContent, Street = row.QuerySelector(" tr td:nth-child(2)").TextContent, Disconnectdate = row.QuerySelector("tr td:nth-child(7)").TextContent, Disconnecthour = row.QuerySelector("tr td:nth-child(8)").TextContent, Connectdate = row.QuerySelector("tr td:nth-child(9)").TextContent, Connecthour = row.QuerySelector("tr td:nth-child(10)").TextContent }; results.Add(shutdown); } return(results); }
public async Task AddCurrentShutdown(CurrentShutdown item) { await _context.Shutdowns.InsertOneAsync(item); }