private static async Task <List <FreelanceOffer> > ParseHtml(string source) { var result = new List <FreelanceOffer>(); var parser = new HtmlParser(); var document = await parser.ParseAsync(source).ConfigureAwait(false); var proposals = document.GetElementsByClassName("j-order"); bool reached = false; foreach (var item in proposals) { try { FreelanceOffer offer = new FreelanceOffer(); var title = item.GetElementsByClassName("l-project-title").First().GetElementsByTagName("a").First(); offer.Theme = title.InnerHtml; offer.Link = title.GetAttribute("href"); offer.Price = item.GetElementsByClassName("l-price_na").Concat(item.GetElementsByClassName("l-price")).First().InnerHtml; offer.Details = item.GetElementsByTagName("p").First().InnerHtml; if (!reached) { reached = offer.Theme == Settings.Default.LastFreelanceTheme; } offer.Watched = reached; result.Add(offer); } catch { continue; } } Settings.Default.LastFreelanceTheme = result.FirstOrDefault().Theme; Settings.Default.Save(); return(result); }
override public void RefreshData() { Offers = new NotifyTaskCompletion <List <FreelanceOffer> >(FreelanceOffer.GetOffers()); }