I'm trying to make a time schedule telegram bot for my university, in order to do so I used HtmlAgilityPack to get data from university html table into Pair Object(A simple object with Date, Time, Discipline,Lecturers Name, Auditorium properties). The thing is it pulls cells, but I need to compose it into a Pair Object, so that I can then return an object for the users request. I think I need to use LINQ, but I don't have much experience with it. Further, the object.Date parameter will be used to compare the current date with the property date to return the whole schedule. My code is as following:
public List<Pair> Scrape(string groupNumber)
{
//this gets all the cells in an html table
string groupUrl = _websiteUrl + groupNumber + ".xml";
var web = new HtmlWeb();
var doc = web.Load(groupUrl);
var htmlTableCell = from table in doc.DocumentNode.SelectNodes("/html/body/div[6]/div[2]/div/table").Cast<HtmlNode>()
from row in table.SelectNodes("//tr").Cast<HtmlNode>()
from cell in row.SelectNodes("th|td").Cast<HtmlNode>()
select new { CellText = cell.InnerText};
//this shows all the cells in a logger
foreach(var cell in htmlTableCell)
{
_logger.LogCritical(cell.CellText);
}
return _pairs;
}