private List <TorrentLeechEntry> Fetch(string url) { var doc = new HtmlDocument(); doc.LoadHtml(_browserClient.DownloadString(url)); return(doc.DocumentNode.SelectNodes("//*[@id='torrenttable']/tbody/tr").Select(o => new TorrentLeechEntry(o, _browserClient)).ToList()); }
public Wikipedia(string url) { var bc = new BrowserClient(); var html = bc.DownloadString(url); var doc = new HtmlDocument(); doc.LoadHtml(html); try { var image = "http:" + doc.DocumentNode .SelectNodes("//table").First(o => o.Attributes["class"] != null && o.Attributes["class"].Value.Contains("infobox")) .SelectNodes(".//a[@class='image']/img") .OrderByDescending(o => int.Parse(o.Attributes["width"].Value)) .First().Attributes["src"].Value; ImageView.Create(image, url); }catch { } var count = 0; _description = ""; foreach (var text in doc.DocumentNode.SelectNodes("//p").Select(o => o.InnerText.RemoveBrackets())) { foreach (var sentence in text.RegexSplit(@"\.\n|\. ").Where(o => !string.IsNullOrWhiteSpace(o)).Select(o => o.Trim())) { _description += sentence + (sentence.EndsWith(".") ? "" : ".") + Environment.NewLine; if (_description.Length > 300) goto BreakLoops; } } BreakLoops: _description = _description.HtmlDecode().Trim(); }
public Wikipedia(string url) { var bc = new BrowserClient(); var html = bc.DownloadString(url); var doc = new HtmlDocument(); doc.LoadHtml(html); try { var image = "http:" + doc.DocumentNode.SelectNodes("//table").First( o => o.Attributes["class"] != null && o.Attributes["class"].Value.Contains("infobox")) .SelectNodes(".//a[@class='image']/img") .OrderByDescending(o => int.Parse(o.Attributes["width"].Value)) .First().Attributes["src"].Value; ImageView.Create(image, url); } catch { } _description = ""; foreach (var text in doc.DocumentNode.SelectNodes("//p").Select(o => o.InnerText.RemoveBrackets())) { foreach(var sentence in text.RegexSplit(@"\.\n|\. ").Where(o => !string.IsNullOrWhiteSpace(o)).Select(o => o.Trim())) { var _sentence = sentence.RegexRemove("\\(.+?\\)"); _description += _sentence + (_sentence.EndsWith(".") ? "" : ".") + Environment.NewLine; if (_description.Length > 300) goto BreakLoops; } } BreakLoops: _description = _description.HtmlDecode().Trim(); }