public bool RGP(int PageNum = 1) { string url = "http://rgporn.com/index.php?newsid=" + PageNum; //tel.Update(txtURL, url); string html = web.DownloadHTML(url); if (html == "") { return(false); } resultLines = xml.Parse_HTML_XML(html, "//body/div/div/div/div/table/tbody/tr/td/div/div/div/p"); // extract sections of text from html xml // extract tags string display = "TAGS: "; List <string> tags = new List <string>(); string Tags = ""; foreach (string line in resultLines) { if (line.Contains("=tags")) { string tag = line.Replace("<a", ""); tag = tag.Replace("</a>", ""); tag = ahk.StringSplit(tag, ">", 1); tag = tag.Trim(); tags.Add(tag); display = display + "\n" + tag; if (Tags != "") { Tags = Tags + "|" + tag; } if (Tags == "") { Tags = tag; } } } // extract title List <string> titleLines = xml.Parse_HTML_XML(html, "//body/div/div/div/div/table/tbody/tr/td/div/div/div"); // extract sections of text from html xml string title = lst.Return_List_Value(titleLines, 2); title = title.Replace("<h1 class=\"shead\">", ""); title = title.Replace("</h1>", ""); string imagehtml = ""; foreach (string ima in titleLines) { if (ima.Contains(".jpg")) { imagehtml = imagehtml + "\n" + ima; } } //ahk.MsgBox(title); List <string> links = rg.Regex_RGLinks(html); bool AllOnline = true; int onlineLinkCount = 0; string linkText = ""; foreach (string link in links) { RGInfo info = rg.RapidGatorCheckStatus(link); if (!info.FileOnline) { AllOnline = false; } else { onlineLinkCount++; } string wlink = link + "|" + info.FileSize; if (linkText != "") { linkText = linkText + "\n" + wlink; } if (linkText == "") { linkText = wlink; } } string linksMsg = onlineLinkCount + "/" + links.Count + " Links Online"; // Extract / Display Images From Page int downloaded = 0; if (AllOnline) { string SaveDir = ahk.AppDir() + "\\Posts\\RGP\\" + ahk.AddLeadingZeros(PageNum, 5).ToString(); ahk.FileCreateDir(SaveDir); ahk.Sleep(500); ahk.FileAppend(Tags, SaveDir + "\\Tags.txt"); ahk.FileAppend(title, SaveDir + "\\Title.txt"); ahk.FileAppend(linkText, SaveDir + "\\Links.txt"); downloaded = DownloadImages(imagehtml, SaveDir, ahk.AddLeadingZeros(PageNum, 5).ToString()); //tel.Update(txtResults, "Title: " + title + "\n\nTags: " + Tags + "\n\n" + linksMsg); } //ahk.MsgBox("Found " + links.Count + " Links\nDownloaded " + downloaded.ToString() + " + Images"); return(AllOnline); }
/// <summary>Add leading zeros to an int/string, ex: InNumber 12 with TotalReturnLength 5 returns string "00012"</summary> /// <param name="InNumber">Original number (int or string) to add leading zeros to.</param> /// <param name="TotalReturnLength">Total # of desired digits, adding zeros in front of the InNumber to ensure return value is TotalReturnLength characters long.</param> /// <tested>True</tested> public static string AddLeadingZeros(this object InNumber, int TotalReturnLength = 5) { _AHK ahk = new _AHK(); return(ahk.AddLeadingZeros(InNumber, TotalReturnLength)); }