private async Task LoadDataTask() { FileProgramList.Clear(); string reqUri = "index.php?action=gate&a2=files"; string responseString = await SendRequest.GET(reqUri); if (string.IsNullOrEmpty(responseString)) { Console.WriteLine("Load program: null"); return; } HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(responseString); HtmlNode node = doc.DocumentNode.SelectSingleNode(@"//form[@name='frm_files']/table"); HtmlNodeCollection childs = node.ChildNodes; string[] stringSeparators = new string[] { "'" }; foreach (HtmlNode n in childs) { if (n.Name.Equals("script") && n.InnerText.Contains("document.write")) { string text = n.InnerText; string[] splits = text.Split(stringSeparators, StringSplitOptions.None); string encoded = splits[1]; string decoded = WebUtility.UrlDecode(encoded); AddProgram(decoded); } } }
private void AddProgram(string decoded) { try { FileProgramModel p = new FileProgramModel(); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(decoded); HtmlNode node = doc.DocumentNode.SelectSingleNode(@"//tr/td[@class='sni']"); p.Id = node.InnerText; node = doc.DocumentNode.SelectSingleNode(@"//tr/td[@class='p1']"); p.Type = node.InnerText; node = doc.DocumentNode.SelectSingleNode(@"//tr/td[@class='sm2']"); p.Version = Convert.ToDouble(node.InnerText); HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes(@"//tr/td[@class='sm']"); p.Name = nodes[0].InnerText; string size = nodes[1].InnerText; string[] seperate = { " " }; string[] splits = size.Split(seperate, StringSplitOptions.None); switch (splits[1]) { case "Mb": p.Size = Convert.ToInt64(Convert.ToDouble(splits[0]) * 1024); break; case "Gb": p.Size = Convert.ToInt64(Convert.ToDouble(splits[0]) * 1024 * 1024); break; } nodes = doc.DocumentNode.SelectNodes(@"//a"); foreach (HtmlNode n in nodes) { string href = n.Attributes[0].Value; if (href.Contains("run")) { p.Run = href; } else if (href.Contains("delete")) { p.Delete = href; } else if (href.Contains("unhide")) { p.Unhide = href; } else if (href.Contains("hide")) { p.Hide = href; } else if (href.Contains("encrypt")) { p.Encrypt = href; } else if (href.Contains("decrypt")) { p.Decrypt = href; } else if (href.Contains("Public")) { p.Public = href; } else if (href.Contains("Private")) { p.Private = href; } else if (href.Contains("upload")) { p.Upload = href; } else if (href.Contains("download")) { p.Download = href; } } FileProgramList.Add(p); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }