/// <summary> /// Get Comments of the particular images /// </summary> /// <param name="source"></param> /// <returns></returns> private string getComments(string source) { string comments = string.Empty; string startString = "<div class=\"comment_body\">"; string endString = "<span class=\"time\">"; string zone = string.Empty; try { if (source.Contains(startString) && source.Contains(endString)) { try { zone = ScrapUserName.getBetween(source, startString, endString); } catch { } } if (!string.IsNullOrEmpty(zone)) { try { zone = ScrapUserName.getBetween(zone, "<strong>", "</strong>"); if (zone.Contains("<span")) { string badText = string.Empty; try { badText = ScrapUserName.getBetween(zone, "<span", "</span>"); } catch { } if (!string.IsNullOrEmpty(badText)) { zone = zone.Replace(badText, string.Empty); zone = zone.Substring(0, zone.IndexOf("<span")); } } } catch { } } if (!string.IsNullOrEmpty(zone)) { if (!zone.Contains("<a href")) { comments = zone; comments = comments.Trim(); } else { string[] arrZone = Regex.Split(zone, "<a href"); comments = arrZone[0]; comments = comments.Trim(); arrZone = arrZone.Skip(1).ToArray(); foreach (string item_arrZone in arrZone) { try { comments = comments + " " + ScrapUserName.getBetween(item_arrZone, ">", "</a>"); } catch { } } comments.Trim(); } }//End of if (!string.IsNullOrEmpty(zone)) } catch { } if (comments.Contains("<br/>")) { comments = comments.Replace("<br/>", " "); } if (comments.Contains("\n")) { comments = comments.Replace("\n", string.Empty); } return(comments); }
public void startDownloadingImage(string itemImageTag, int delay) { string pageSource = string.Empty; List <string> lstCountScrape = new List <string>(); if (stopScrapImageBool) { return; } //try //{ GlobDramProHttpHelper _GlobusHttpHelper = new GlobDramProHttpHelper(); try { pageSource = _GlobusHttpHelper.getHtmlfromUrl(new Uri(mainUrl), ""); } catch { } string url = string.Empty; if (!string.IsNullOrEmpty(pageSource)) { if (itemImageTag.Contains("#")) { itemImageTag = itemImageTag.Replace("#", "%23"); url = mainUrl + "tag/" + itemImageTag.Replace("%23", string.Empty); } else { url = mainUrl + "n/" + itemImageTag.Replace("%23", string.Empty); } try { pageSource = _GlobusHttpHelper.getHtmlfromUrl(new Uri(url), ""); } catch { } if (!string.IsNullOrEmpty(pageSource)) { // if (pageSource.Contains("<div class=\"mainimg_wrapper\">")) if (pageSource.Contains("class=\"username\"")) { try { // string[] arr = Regex.Split(pageSource, "<div class=\"mainimg_wrapper\">"); string[] arr = Regex.Split(pageSource, "class=\"username\""); if (arr.Length > 1) { arr = arr.Skip(1).ToArray(); foreach (var item in arr) { string websiteLink = ScrapUserName.getBetween(item, "<a href=\"", "\""); websiteLink = "http://websta.me/" + websiteLink; string imageLink = ScrapUserName.getBetween(item, "src=\"", "\""); string imageid = ScrapUserName.getBetween(item, ".2885-19/", "_a.jpg\">"); string FullName = ScrapUserName.getBetween(item, "\">", "</a>"); lstCountScrape.Add(imageLink); lstCountScrape = lstCountScrape.Distinct().ToList(); if (stopScrapImageBool) { return; } try { if (!string.IsNullOrEmpty(imageLink)) { duplicatlink.Add(imageLink, imageid); string CSVData = websiteLink.Replace(",", string.Empty) + "," + imageLink.Replace(",", string.Empty) + "," + imageid.Replace(",", string.Empty) + "," + FullName.Replace(",", string.Empty); GramBoardProFileHelper.ExportDataCSVFile(CSVHeader, CSVData, CSVPath); classsforlogger objclasssforlogger = new classsforlogger(); objclasssforlogger.AddToImageTagLogger("[ " + DateTime.Now + " ] => [ websiteLink : " + websiteLink + " imageLink : " + imageLink + " imageid : " + imageid + " FullName : " + FullName); //frm_stagram objbbbFrmMain = (frm_stagram)Application.OpenForms["frm_stagram"]; //objbbbFrmMain.lstImageLogger.Items.Add("hey ram"); if (lstCountScrape.Count >= ClGlobul.countNOOfFollowersandImageDownload) { return; } } } catch { } if (stopScrapImageBool) { return; } try { classsforlogger objclasssforlogger = new classsforlogger(); lock (_lockObject) { try { frm_stagram objfrm_stagram = (frm_stagram)Application.OpenForms["frm_stagram"]; if (!string.IsNullOrEmpty(objfrm_stagram.txtmaxDelayGetImageImage.Text) && NumberHelper.ValidateNumber(objfrm_stagram.txtmaxDelayGetImageImage.Text)) { mindelay = Convert.ToInt32(objfrm_stagram.txtmaxDelayGetImageImage.Text); } if (!string.IsNullOrEmpty(objfrm_stagram.txtminDelayGetImageImage.Text) && NumberHelper.ValidateNumber(objfrm_stagram.txtminDelayGetImageImage.Text)) { maxdelay = Convert.ToInt32(objfrm_stagram.txtminDelayGetImageImage.Text); } Random obj_rn = new Random(); int delay1 = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay); delay1 = obj_rn.Next(mindelay, maxdelay); objclasssforlogger.AddToImageTagLogger("[ " + DateTime.Now + " ] => [ Delay For " + delay1 + " Seconds ]"); Thread.Sleep(delay1 * 1000); } catch { } } //HashLogger.printLogger("[ " + DateTime.Now + " ] => [ " + imageId + " ]"); //HashLogger.printLogger("[ " + DateTime.Now + " ] => [ Delay for " + delay + " seconds ]"); objclasssforlogger.AddToImageTagLogger("[ " + DateTime.Now + " ] => [ " + websiteLink + " ]"); //objclasssforlogger.AddToImageTagLogger("[ " + DateTime.Now + " ] => [ Delay for " + delay + " seconds ]"); //Thread.Sleep(delay * 1000); if (lstCountScrape.Count >= ClGlobul.countNOOfFollowersandImageDownload) { return; } } catch { }; } } if (lstCountScrape.Count >= ClGlobul.countNOOfFollowersandImageDownload) { return; } } catch { }; } } } classsforlogger objclasssforlogger1 = new classsforlogger(); objclasssforlogger1.AddToImageTagLogger("[ " + DateTime.Now + " ] => [ Process Completed ]"); }