public ComicInfo LoadUri(Uri Uri) { CurrentHost = Uri.Host; string CurrentHtml = Encoding.UTF8.GetString(TryDownload(Uri)); if (CurrentHtml.IsCloudflareTriggered()) { Cloudflare = JSTools.BypassCloudflare(Uri.AbsoluteUri); CurrentHtml = Encoding.UTF8.GetString(TryDownload(Uri)); } Document = new HtmlDocument(); Document.LoadHtml(CurrentHtml); ComicInfo Info = new ComicInfo(); Info.Title = Document.Descendants("title").First().InnerText; Info.Title = HttpUtility.HtmlDecode(Info.Title); Info.Title = Info.Title.Substring(0, Info.Title.LastIndexOf("-")).Trim(); Info.Cover = TryDownload(new Uri(Document .SelectSingleNode("//img[@class=\"img-thumbnail\"]") .GetAttributeValue("src", ""))); Info.ContentType = ContentType.Comic; return(Info); }
public ComicInfo LoadUri(Uri Uri) { string CurrentHtml = Encoding.UTF8.GetString(TryDownload(Uri)); if (CurrentHtml.IsCloudflareTriggered()) { Cloudflare = JSTools.BypassCloudflare(Uri.AbsoluteUri); CurrentHtml = Encoding.UTF8.GetString(TryDownload(Uri)); } Document = new HtmlDocument(); Document.LoadHtml(CurrentHtml); ComicInfo Info = new ComicInfo(); Info.Title = Document.SelectSingleNode("//div[@class=\"info-title\"]/h1").InnerText; Info.Title = HttpUtility.HtmlDecode(Info.Title); Info.Cover = TryDownload(new Uri(Document .SelectSingleNode("//div[contains(@class, \"info-img\")]/img") .GetAttributeValue("src", ""))); Info.ContentType = ContentType.Comic; return(Info); }
public ComicInfo LoadUri(Uri Uri) { Cookies = new CookieContainer(); CurrentUrl = Uri; ReverseChapters = Uri.Host.ToLower().Contains("manga47.com"); Document.LoadUrl(Uri, Cookies: Cookies); if (string.IsNullOrWhiteSpace(Document.ToHTML()) || Document.IsCloudflareTriggered()) { CFData = JSTools.BypassCloudflare(Uri.AbsoluteUri); Document.LoadHtml(CFData?.HTML); } ComicInfo Info = new ComicInfo(); var TitleNode = Document.SelectSingleNode("//div[@class='post-title']/*[self::h3 or self::h2 or self::h1]"); try { TitleNode.RemoveChild(TitleNode.ChildNodes.Where(x => x.Name == "span").Single()); } catch { } Info.Title = TitleNode.InnerText.Trim(); if (Info.Title.ToUpper().StartsWith("HOT")) { Info.Title = Info.Title.Substring(3); } Info.Title = HttpUtility.HtmlDecode(Info.Title).Trim(); var ImgNode = Document.SelectSingleNode("//div[@class='summary_image']/a/img"); var ImgUrl = ImgNode.GetAttributeValue("data-lazy-srcset", ""); if (string.IsNullOrWhiteSpace(ImgUrl)) { ImgUrl = ImgNode.GetAttributeValue("data-src", ""); } else { ImgUrl = ImgUrl.Trim().Split(',', ' ').First(); } if (string.IsNullOrWhiteSpace(ImgUrl)) { ImgUrl = ImgNode.GetAttributeValue("src", ""); } if (string.IsNullOrWhiteSpace(ImgUrl)) { ImgUrl = ImgNode.GetAttributeValue("data-cfsrc", ""); } if (ImgUrl.StartsWith("//")) { ImgUrl = "http:" + ImgUrl; } Info.Cover = ImgUrl.TryDownload(CFData); Info.ContentType = ContentType.Comic; return(Info); }
private HtmlDocument GetChapterHtml(int ID) { HtmlDocument Document = new HtmlDocument(); string HTML = Encoding.UTF8.GetString(TryDownload(new Uri(ChapterLinks[ID]))); while (HTML.IsCloudflareTriggered()) { Cloudflare = JSTools.BypassCloudflare(ChapterLinks[ID]); HTML = Encoding.UTF8.GetString(TryDownload(new Uri(ChapterLinks[ID]))); } Document.LoadHtml(HTML); return(Document); }
public ComicInfo LoadUri(Uri Uri) { Cookies = new CookieContainer(); CurrentUrl = Uri; Document.LoadUrl(Uri, Cookies: Cookies); if (string.IsNullOrWhiteSpace(Document.ToHTML()) || Document.IsCloudflareTriggered()) { CFData = JSTools.BypassCloudflare(Uri.AbsoluteUri); Document.LoadHtml(CFData?.HTML); } ComicInfo Info = new ComicInfo(); Info.Title = HttpUtility.HtmlDecode(Document.SelectSingleNode("//*[(self::h1 or self::h2 or self::h3) and @class='entry-title']").InnerText.Trim()); var ImgNode = Document.SelectSingleNode("//div[@class='thumb']/img"); var ImgUrl = ImgNode.GetAttributeValue("data-lazy-srcset", ""); if (string.IsNullOrWhiteSpace(ImgUrl)) { ImgUrl = ImgNode.GetAttributeValue("data-src", ""); } else { ImgUrl = ImgUrl.Trim().Split(',', ' ').First(); } if (string.IsNullOrWhiteSpace(ImgUrl)) { ImgUrl = ImgNode.GetAttributeValue("src", ""); } if (string.IsNullOrWhiteSpace(ImgUrl)) { ImgUrl = ImgNode.GetAttributeValue("data-cfsrc", ""); } if (ImgUrl.StartsWith("//")) { ImgUrl = "http:" + ImgUrl; } Info.Cover = ImgUrl.TryDownload(CFData); Info.ContentType = ContentType.Comic; return(Info); }
private byte[] TryDownload(Uri Url, string Referer = "https://mangadex.org") { if (CFData != null) { return(Url.TryDownload(Referer, CFData?.UserAgent, Cookie: CFData?.Cookies)); } try { return(Url.TryDownload(Referer)); } catch { CFData = JSTools.BypassCloudflare(Url.AbsoluteUri); return(TryDownload(Url, Referer)); } }
private byte[] TryDownload(Uri Url, string Referer = "https://goldenmangas.top") { if (CFData != null) { return(Url.TryDownload(Referer, CFData?.UserAgent, Cookie: CFData?.Cookies)); } try { return(Url.TryDownload(Referer) ?? throw new Exception()); } catch { CFData = JSTools.BypassCloudflare(Url.AbsoluteUri); return(TryDownload(Url, Referer)); } }
public IEnumerable <byte[]> DownloadPages(int ID) { foreach (var PageUrl in GetChapterPages(ID)) { var Page = PageUrl.TryDownload(Referer: CurrentUrl); if (Page == null && CFData != null) { Page = PageUrl.TryDownload(CFData, Referer: CurrentUrl); } if (Page == null) { CFData = JSTools.BypassCloudflare(PageUrl); Page = PageUrl.TryDownload(CFData, Referer: CurrentUrl); } yield return(Page); } }
public IEnumerable <KeyValuePair <int, string> > EnumChapters() { int ID = ChapterLinks.Count; var Nodes = Document.SelectNodes("//div[@class=\"chapter-list\"]/div/span/a"); if (Nodes == null || Nodes.Count <= 0) { var SafeDoc = new HtmlDocument(); if (Document.IsCloudflareTriggered()) { CFData = JSTools.BypassCloudflare(CurrentUrl); SafeDoc.LoadHtml(CFData?.HTML); } else { SafeDoc = Document; } Nodes = SafeDoc.SelectNodes("//div[@class=\"chapter-list\"]/div/span/a"); if (Nodes == null || Nodes.Count <= 0) { Nodes = SafeDoc.SelectNodes("//a[@class=\"chapter-name text-nowrap\"]"); } if (Nodes == null || Nodes.Count <= 0) { Nodes = SafeDoc.SelectNodes("//div[@class=\"chapter-list\"]//a"); } } foreach (var Node in Nodes) { string Name = HttpUtility.HtmlDecode(Node.InnerText).ToLower(); string Link = Node.GetAttributeValue("href", string.Empty); if (!Name.ToLower().Contains("chapter")) { if (Link.ToLower().Contains("chapter")) { Name = Link.Substring("chapter"); } Name = (from x in Name.Split(' ', '-', '_') where double.TryParse(x, out _) select x).First(); } else { Name = Name.Substring("chapter").Trim(); } if (Name.Contains(":")) { Name = Name.Substring(0, Name.IndexOf(":")); } Link = Link.EnsureAbsoluteUrl(CurrentUrl); ChapterNames[ID] = DataTools.GetRawName(Name); ChapterLinks[ID] = Link; yield return(new KeyValuePair <int, string>(ID, ChapterNames[ID++])); } }