List <NineAnimeDataSearch> Search(string search) { List <NineAnimeDataSearch> searchData = new List <NineAnimeDataSearch>(); try { string url = NineAnimeSite + "/search?keyword=" + search; string d = DownloadString(url); if (!d.IsClean()) { return(null); } var doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(d); print("9anime:" + d); var data = doc.QuerySelector("ul.anime-list"); if (data == null) { return(searchData); } var items = data.QuerySelectorAll("> li > a"); if (items == null) { return(searchData); } foreach (var item in items) { string href = item.GetAttributeValue("href", ""); string dataTip = item.GetAttributeValue("data-tip", ""); if (dataTip != "") { string _d = DownloadString((NineAnimeSite + ("/ajax/anime/tooltip/" + dataTip).Replace("//", "/")), referer: url); string _ep = FindHTML(_d, "Episode", "/"); int.TryParse(_ep, out int maxEp); if (maxEp != 0) // IF NOT MOVIE { string otherNames = FindHTML(_d, "<label>Other names:</label>\n <span>", "<").Replace(" ", "").Replace("\n", "").Replace(";", ""); string title = FindHTML(_d, "data-jtitle=\"", "\""); print(maxEp + "|" + title + "|" + otherNames.FString()); bool isDub = title.Contains("(Dub)"); searchData.Add(new NineAnimeDataSearch() { isDub = isDub, maxEp = maxEp, href = href, names = otherNames, title = title.Replace(" (Dub)", "").Replace(" ", "") }); } } } } catch (Exception) { } return(searchData); }
public async Task <IProblem> Load(int number) { using (WebClient client = new WebClient()) { Uri pageUri = new Uri($"https://projecteuler.net/problem={number}"); string html = await client.DownloadStringTaskAsync(pageUri); var doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); var selectedNode = doc.QuerySelector("#content"); var title = selectedNode.QuerySelector("h2").InnerText; var content = selectedNode.QuerySelector(".problem_content").InnerText; return(new Problem(title, content, number)); } }