public static List <MiqoItemPage> GetURLItem(string iItemName, CookieCollection iLogCookies, HtmlDocument iDocument) { List <MiqoItemPage> result = new List <MiqoItemPage>(); CookieCollection oCookies = new CookieCollection(); HttpStatusCode oCode = HttpStatusCode.NotFound; HtmlDocument answer = iDocument; if (null == answer) { answer = Service_Misc.GetWebPageFromRequest("GET https://miqobot.com/forum/forums/topic/index-gathering-grids/ HTTP/1.1|Host: miqobot.com|Connection: keep-alive|Cache-Control: max-age=0|Upgrade-Insecure-Requests: 1|User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36|Sec-Fetch-Mode: navigate|Sec-Fetch-User: ?1|Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3|Sec-Fetch-Site: same-origin|Referer: https://miqobot.com/forum/forums/forum/grids-and-presets/|Accept-Encoding: gzip, deflate, br|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|Cookie: wordpress_test_cookie=WP+Cookie+check; _ga=GA1.2.1771485810.1566089776||", iLogCookies, ref oCookies, ref oCode); } if (null == answer) { return(result); } HtmlNode firstAnswerNode = Service_Misc.GetFirstChildNode(answer.DocumentNode, "div", "topic-tag-gathering"); List <HtmlNode> listItemNodes = firstAnswerNode.Descendants("li").ToList(); foreach (HtmlNode node in listItemNodes) { if (null == node) { continue; } string nodeInnerTextLower = node.InnerText.ToLower(); if (nodeInnerTextLower.Contains("by") && nodeInnerTextLower.Contains(iItemName.ToLower())) { //Found node ! List <HtmlNode> listLinks = node.Descendants("a").ToList(); foreach (HtmlNode link in listLinks) { MiqoItemPage itempage = new MiqoItemPage(); itempage.URL = link.GetAttributeValue("href", ""); itempage.Contributor = link.InnerText; result.Add(itempage); } } } return(result); }
/// <summary> /// Retrieves all aetheryte names and positions from https://ffxiv.consolegameswiki.com/wiki/Zone /// </summary> /// <returns></returns> public static List <FFXIVAetheryte> GetAetherytesFromRegion(string iRegion, string iZoneName, string iPageLink) { List <FFXIVAetheryte> result = new List <FFXIVAetheryte>(); DirectoryInfo exeDirectory = new DirectoryInfo(Service_Misc.GetExecutionPath()); DirectoryInfo metadataDirectory = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "Metadata")); //Main zone page CookieCollection oCookies = new CookieCollection(); HttpStatusCode oCode = HttpStatusCode.NotFound; HtmlDocument answer = Service_Misc.GetWebPageFromRequest("GET https://ffxiv.consolegameswiki.com" + iPageLink + " HTTP/1.1|Host: ffxiv.consolegameswiki.com|Connection: keep-alive|Pragma: no-cache|Cache-Control: no-cache|Upgrade-Insecure-Requests: 1|User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36|Sec-Fetch-User: ?1|Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9|Sec-Fetch-Site: same-origin|Sec-Fetch-Mode: navigate|Referer: https://ffxiv.consolegameswiki.com/wiki/FF14_Wiki|Accept-Encoding: gzip, deflate|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|Cookie: __cfduid=d64998d831d683525635413f445baf9671577745615; _ga=GA1.2.147161069.1577745617; _gid=GA1.2.132489683.1577745617; trc_cookie_storage=taboola%2520global%253Auser-id%3D8ee6f8c7-39f8-4db7-b620-5868e971d900-tuct4ec3105||", oCookies, ref oCookies, ref oCode); if (null == answer) { return(result); } HtmlNode nodeInfobox = Service_Misc.GetFirstChildNode(answer.DocumentNode, "div", "infobox-n area"); if (null == nodeInfobox) { return(result); } List <HtmlNode> dlNodes = nodeInfobox.Descendants("dl").ToList(); if (dlNodes.Count != 1) { return(result); } foreach (HtmlNode aNode in dlNodes[0].ChildNodes) { if (aNode.Name != "dd") { continue; } string text = aNode.InnerText; List <string> listAetherytes = text.Split(')').ToList(); foreach (string aetheryteText in listAetherytes) { if (aetheryteText.Contains("(X:") && aetheryteText.Contains("Y:")) { string xText = aetheryteText.Split(new string[] { "(X:" }, StringSplitOptions.None)[1].Split(',')[0].Trim(); string yText = aetheryteText.Split(new string[] { "Y:" }, StringSplitOptions.None)[1].Split(')')[0].Split(',')[0].Trim(); string nameText = aetheryteText.Split(new string[] { "(X:" }, StringSplitOptions.None)[0]; double x = 0, y = 0; double.TryParse(xText, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out x); double.TryParse(yText, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out y); FFXIVAetheryte aetheryte = new FFXIVAetheryte(); aetheryte.Region = iRegion; aetheryte.Zone = iZoneName; aetheryte.Name = nameText; //Conversion aetheryte position to map position double offsetX = 0; double offsetY = 0; FileInfo metadataFile = new FileInfo(Path.Combine(metadataDirectory.FullName, aetheryte.Zone + ".txt")); if (!metadataFile.Exists) { offsetX = 0; offsetY = 0; File.WriteAllText(metadataFile.FullName, "21.4;21.4"); } else { string metadata = File.ReadAllText(metadataFile.FullName); List <string> coordinatesMetadata = metadata.Replace(",", ".").Split(';').ToList(); double.TryParse(coordinatesMetadata[0], System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out offsetX); double.TryParse(coordinatesMetadata[1], System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out offsetY); } aetheryte.Position = new FFXIVPosition((x - offsetX) * 50, (y - offsetY) * 50); result.Add(aetheryte); } } } return(result); }