public async Task <string[]> GetLinksAsync() { HtmlLoader loader = new HtmlLoader(); string source = await loader.GetHtmlDocument(Settings.URL); HtmlParser domDocument = new HtmlParser(); IHtmlDocument document = await domDocument.ParseDocumentAsync(source); BesplatkaParser parser = new BesplatkaParser(); string[] links = parser.GetLink(document, COUNT_LOAD_DATA); return(links); }
public async Task <List <BesplatkaDocumentModel> > Worker() { List <BesplatkaDocumentModel> models = new List <BesplatkaDocumentModel>(); string[] links = await GetLinksAsync(); for (int advertIndex = 0; advertIndex < COUNT_LOAD_DATA; advertIndex++) { HtmlLoader loader = new HtmlLoader(); BesplatkaParser parser = new BesplatkaParser(); HtmlParser domDocument = new HtmlParser(); string source = await loader.GetHtmlDocument(links[advertIndex]); IHtmlDocument document = await domDocument.ParseDocumentAsync(source); BesplatkaDocumentModel model = parser.Parse(document); model.Link = links[advertIndex]; models.Add(model); } OnComplete?.Invoke(this); return(models); }