public void startUserScraper(string itemHash, int delay) { string pageSource = string.Empty; string response = string.Empty; string postData = string.Empty; List<string> lstCountScrapUser = new List<string>(); if (stopScrapBool) return; try { GlobDramProHttpHelper _GlobusHttpHelper = new GlobDramProHttpHelper(); pageSource = _GlobusHttpHelper.getHtmlfromUrl(new Uri(mainUrl),""); if (!string.IsNullOrEmpty(pageSource)) { //if (itemHash.StartsWith("#")) //{ // postData = "q=" + Uri.EscapeDataString(itemHash); //} //else //{ // postData = "q=" + Uri.EscapeDataString("#") + itemHash; //} postData = "q=" + Uri.EscapeDataString(itemHash); string url = "http://websta.me/search/" + postData.Substring(postData.IndexOf("=") + 1); string referer = "http://websta.me/"; response = _GlobusHttpHelper.postFormData(new Uri(url), postData, referer, ""); if (!string.IsNullOrEmpty(response)) { if (response.Contains("class=\"username\"")) { try { string[] arrOfUserName = Regex.Split(response, "class=\"username\""); if (arrOfUserName.Length > 0) { arrOfUserName = arrOfUserName.Skip(1).ToArray(); foreach (string itemArray in arrOfUserName) { if (stopScrapBool) return; try { string startString = "href=\"/n/"; string endString = "\">"; if (itemArray.Contains(startString) && itemArray.Contains(endString)) { string userName = string.Empty; try { userName = getBetween(itemArray, startString, endString); lstCountScrapUser.Add(userName); lstCountScrapUser = lstCountScrapUser.Distinct().ToList(); if (!string.IsNullOrEmpty(userLink)) { duplicateurl.Add(userLink + userName, userLink + userName); #region CSV Write try { string CSVData = itemHash.Replace(",", string.Empty) + "," + userName.Replace(",", string.Empty) + "," + (userLink + userName).Replace(",", string.Empty); GramBoardProFileHelper.ExportDataCSVFile(CSVHeader, CSVData, CSVPath); } catch { } try { GramBoardLogHelper.log.Info("["+ userName +","+ "itemHash:" +","+ itemHash +","+ "userName:"******","+ userName +","+ "userLink:" +","+ userLink + ","+" UserName" +userName +"]"); } catch { }; #endregion try { if (stopScrapBool) return; lock (_lockObject) { try { GramBoardLogHelper.log.Info("=> [ UserName" + userName + " ]"); //HashLogger.printLogger("[ " + DateTime.Now + " ] => [ Delay for " + delay + " seconds ]"); //GramBoardLogHelper.log.Info(" => [ Delay for " + delay + " seconds ]"); //Thread.Sleep(delay * 1000); frm_stagram objfrm_stagram = (frm_stagram)Application.OpenForms["frm_stagram"]; if (!string.IsNullOrEmpty(objfrm_stagram.txtDelayHashTag.Text) && NumberHelper.ValidateNumber(objfrm_stagram.txtDelayHashTag.Text)) { mindelay = Convert.ToInt32(objfrm_stagram.txtDelayHashTag.Text); } if (!string.IsNullOrEmpty(objfrm_stagram.MinHashTagMinDelay.Text) && NumberHelper.ValidateNumber(objfrm_stagram.MinHashTagMinDelay.Text)) { maxdelay = Convert.ToInt32(objfrm_stagram.MinHashTagMinDelay.Text); } Random obj_rn = new Random(); int delay1 = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay); delay1 = obj_rn.Next(mindelay, maxdelay); GramBoardLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Delay For " + delay1 + " Seconds ]"); Thread.Sleep(delay1 * 1000); } catch { } } if (lstCountScrapUser.Count >= ClGlobul.countNOOfFollowersandImageDownload) { return; } } catch { } } } catch { } } } catch { } } } } catch { } } }//End of if (!string.IsNullOrEmpty(response)) else { //Do Nothing yet } }//End of if (!string.IsNullOrEmpty(pageSource)) } catch { } //GlobusLogHelper.log.Info("[" + DateTime.Now + " ]=>[Process Completed]"); //HashLogger.printLogger("[ " + DateTime.Now + " ] => [ Process Completed ]"); }
public string MyLoginForUnfollow(ref GlobDramProHttpHelper _GlobusHttpHelper, string url, string commentPostData, string referrer) { Log("[ " + DateTime.Now + " ] => [ Logging in with Account : " + Username + " ]"); string Status = string.Empty; try { string firstUrl = "https://api.instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes"; //https://instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes string secondURL = "https://instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes"; string res_secondURL = string.Empty; if (!string.IsNullOrEmpty(proxyAddress) && !string.IsNullOrEmpty(proxyPort)) { try { res_secondURL = _GlobusHttpHelper.getHtmlfromUrlProxy(new Uri(secondURL), proxyAddress, Convert.ToInt32(proxyPort), proxyUsername, proxyPassword); } catch (Exception ex) { } } else { try { res_secondURL = _GlobusHttpHelper.getHtmlfromUrlProxy(new Uri(secondURL), "", 80, "", ""); } catch { } } string nextUrl = "https://instagram.com/accounts/login/?force_classic_login=&next=/oauth/authorize/%3Fclient_id%3D9d836570317f4c18bca0db6d2ac38e29%26redirect_uri%3Dhttp%3A//websta.me/%26response_type%3Dcode%26scope%3Dcomments%2Brelationships%2Blikes"; string res_nextUrl = _GlobusHttpHelper.getHtmlfromUrl(new Uri("http://websta.me/login"), ""); //Get Token Number of Id int FirstPointToken_nextUrl = res_nextUrl.IndexOf("csrfmiddlewaretoken"); string FirstTokenSubString_nextUrl = res_nextUrl.Substring(FirstPointToken_nextUrl); int SecondPointToken_nextUrl = FirstTokenSubString_nextUrl.IndexOf("/>"); this.Token = FirstTokenSubString_nextUrl.Substring(0, SecondPointToken_nextUrl).Replace("csrfmiddlewaretoken", string.Empty).Replace("value=", string.Empty).Replace("\"", string.Empty).Replace("'", string.Empty).Trim(); string login = "******"; string postdata_Login = "******" + this.Token + "&username="******"&password="******""; string res_postdata_Login = _GlobusHttpHelper.postFormData(new Uri(login), postdata_Login, login, ""); if (res_postdata_Login.Contains("Please enter a correct username and password")) { //Status = "Failed"; this.LoggedIn = false; } else if (res_postdata_Login.Contains("requesting access to your Instagram account") || postdata_Login.Contains("is requesting to do the following")) { //Status = "AccessIssue"; } else if (res_postdata_Login.Contains("logout") || postdata_Login.Contains("LOG OUT")) { //Status = "Success"; string zone = string.Empty; if (res_postdata_Login.Contains("data('userid'") && res_postdata_Login.Contains(")")) { try { zone = ScrapUserName.getBetween(res_postdata_Login, "data('userid'", ")"); if (!string.IsNullOrEmpty(zone)) { try { int start = zone.IndexOf("'"); int end = zone.LastIndexOf("'"); Status = zone.Substring(start + 1, end - start - 1); } catch { } } } catch { } } Log("[ " + DateTime.Now + " ] => [ Logged in with Account :" + Username + " ]"); this.LoggedIn = true; } //nameval.Clear(); return Status; } catch (Exception ex) { return ex.Message; } }
public void getpageSourceFromProxy(object item) { if (proxyStop) { return; } try { Thread.CurrentThread.IsBackground = true; lstProxyThread.Add(Thread.CurrentThread); lstProxyThread = lstProxyThread.Distinct().ToList(); } catch { } countParseProxiesThreads++; Array Item_value = (Array)item; string ClGlobul_ProxyList_item = (string)Item_value.GetValue(0); DemoStagramPro.frm_stagram frm1 = new DemoStagramPro.frm_stagram(); Globussoft.GlobDramProHttpHelper GlobusHttpHelper = new Globussoft.GlobDramProHttpHelper(); ChilkatHttpHelpr objchilkat = new ChilkatHttpHelpr(); string proxyad = string.Empty; string proxyport = string.Empty; string proxyusername = string.Empty; string proxyPassword = string.Empty; string pagesource1 = string.Empty; string pagesource = string.Empty; try { string[] proxyLst = ClGlobul_ProxyList_item.Split(':'); if (proxyLst.Count() > 3) { proxyad = proxyLst[0]; proxyport = proxyLst[1]; proxyusername = proxyLst[2]; proxyPassword = proxyLst[3]; } else if (proxyLst.Count() > 0 && proxyLst.Count() < 3) { proxyad = proxyLst[0]; proxyport = proxyLst[1]; } else { return; } try { if (proxyStop) { return; } //pagesource1 = GlobusHttpHelper.getHtmlfromUrlProxy(new Uri("http://websta.me/login"), proxyad, Convert.ToInt16(proxyport), proxyusername, proxyPassword); pagesource1 = GlobusHttpHelper.getHtmlfromUrlProxy(new Uri("http://web.stagram.com/"), proxyad, Convert.ToInt16(proxyport), proxyusername, proxyPassword); } catch { }; try { // pagesource1 = GlobusHttpHelper.getHtmlfromUrlProxy(new Uri("http://web.stagram.com/"), proxyad, Convert.ToInt16(proxyport), proxyusername, proxyPassword); pagesource1 = objchilkat.GetHtmlProxy("http://web.stagram.com/", proxyad, proxyport, proxyusername, proxyPassword); } catch { }; //int FirstPointClientId = pagesource1.IndexOf("client_id="); //string FirstClientIdSubString = pagesource1.Substring(FirstPointClientId); //int SecondPointClientId = FirstClientIdSubString.IndexOf("&redirect_uri="); //string ClientId = FirstClientIdSubString.Substring(0, SecondPointClientId).Replace("'", string.Empty).Replace("client_id=", string.Empty).Trim(); //string LoginUrl = "https://instagram.com/accounts/login/?next=/oauth/authorize/%3Fclient_id%3D" + ClientId + "%26redirect_uri%3Dhttp%253A%252F%252Fweb.stagram.com%252F%26response_type%3Dcode%26scope%3Dlikes%2Bcomments%2Brelationships"; //pagesource = GlobusHttpHelper.getHtmlfromUrlProxy(new Uri(LoginUrl), proxyad, Convert.ToInt16(proxyport), proxyusername, proxyPassword); //if (string.IsNullOrEmpty(pagesource)) //{ // pagesource = string.Empty; // pagesource = GlobusHttpHelper.getHtmlfromUrlProxy(new Uri(LoginUrl), proxyad, Convert.ToInt16(proxyport), proxyusername, proxyPassword); //} //ADD in List list of Finally chacked..... if (!string.IsNullOrEmpty(pagesource1)) { if (proxyStop) { return; } addInFinalCheckedProxyist(proxyad, proxyport, proxyusername, proxyPassword, pagesource1); } else { if (proxyStop) { return; } DemoStagramPro.ClGlobul.isProxyCheckComplete = true; LoggerProxy("[ " + DateTime.Now + " ] => [ Proxy Is not Working : " + proxyad + ":" + proxyport + ":" + proxyusername + ":" + proxyPassword + " ]"); lock (lockerforNonWorkingProxies) { GramBoardProFileHelper.AppendStringToTextfileNewLine(proxyad + ":" + proxyport + ":" + proxyusername + ":" + proxyPassword, GramBoardProFileHelper.NonWorkingProxiesList); } } } catch (Exception) { if (proxyStop) { return; } LoggerProxy("[ " + DateTime.Now + " ] => [ Proxy Is not Working : " + proxyad + ":" + proxyport + ":" + proxyusername + ":" + proxyPassword + " ]"); lock (lockerforNonWorkingProxies) { GramBoardProFileHelper.AppendStringToTextfileNewLine(proxyad + ":" + proxyport + ":" + proxyusername + ":" + proxyPassword, GramBoardProFileHelper.NonWorkingProxiesList); } } finally { lock (lockerforProxies) { countParseProxiesThreads--; Monitor.Pulse(lockerforProxies); } Proxystatus--; if (Proxystatus == 0) { LoggerProxy("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]"); LoggerProxy("-----------------------------------------------------------------------------------------------------------------------------------"); } } }
public void startDownloadingImage(string itemImageTag) { try { Thread.CurrentThread.IsBackground = true; Lst_photoLikethread.Add(Thread.CurrentThread); Lst_photoLikethread = Lst_photoLikethread.Distinct().ToList(); } catch (Exception ex) { GramBoardProFileHelper.AppendStringToTextfileNewLine("------------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForPhotolike); GramBoardProFileHelper.AppendStringToTextfileNewLine(DateTime.Now + ":=> Methode Name => unlike :=> " + ex.Message, GramBoardProFileHelper.ErrorLogFilePathForPhotolike); GramBoardProFileHelper.AppendStringToTextfileNewLine("------------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForPhotolike); } string pageSource = string.Empty; int counter = 0; GlobDramProHttpHelper objGlobusHttpHelper = new GlobDramProHttpHelper(); List<string> lstCountImage = new List<string>(); string url = string.Empty; string mainUrl = "http://websta.me/"; if (IsDownLoadImageUsingHashTag) { url = mainUrl + "tag/" + itemImageTag.Replace("#",string.Empty); AddTophotoLogger("[ " + DateTime.Now + " ] =>[Process Using HashTag =" + itemImageTag); } else if (IsDownLoadImageUsingUserName) { url = mainUrl + "n/" + itemImageTag; AddTophotoLogger("[ " + DateTime.Now + " ] =>[Process Selected Using UserName ="******"tag/" + itemImageTag; // AddTophotoLogger("Process Using HashTag =" + itemImageTag); AddTophotoLogger("[ " + DateTime.Now + " ] =>[Process Using HashTag" + itemImageTag); } try { pageSource = objGlobusHttpHelper.getHtmlfromUrl(new Uri(url),""); } catch { } if (string.IsNullOrEmpty(pageSource)) { pageSource = objGlobusHttpHelper.getHtmlfromUrl(new Uri(url),""); } if (!string.IsNullOrEmpty(pageSource)) { if (pageSource.Contains("<div class=\"mainimg_wrapper\">")) { string[] arr = Regex.Split(pageSource, "<div class=\"mainimg_wrapper\">"); if (arr.Length > 1) { arr = arr.Skip(1).ToArray(); foreach (string itemarr in arr) { try { string startString = "<a href=\""; string endString = "\" class=\"mainimg\""; string imageId = string.Empty; string imageSrc = string.Empty; if (itemarr.Contains("<a href=\"/p/")) { int indexStart = itemarr.IndexOf("<a href=\"/p/"); string itemarrNow = itemarr.Substring(indexStart); if (itemarrNow.Contains(startString) && itemarrNow.Contains(endString)) { try { //FileData imageId = getBetween(itemarrNow, startString, endString).Replace("/", ""); } catch { } if (!string.IsNullOrEmpty(imageId)) { //counter++; //imageId = "http://websta.me"+imageId; } } if (itemarrNow.Contains("<img src=\"")) { try { imageSrc = getBetween(itemarrNow, "<img src=\"", "\""); } catch { } counter++; SaveImageWithUrl(imageSrc, FileData, imageId + "_" + counter);//FileData //Globals.imageDesktopPath lstCountImage.Add(imageSrc); lstCountImage = lstCountImage.Distinct().ToList(); // AddTophotoLogger("Image DownLoaded with ImageName " + imageId + "_" + counter); AddTophotoLogger("[ " + DateTime.Now + " ] =>[Image DownLoaded with user="******"_" + imageId + "_" + counter); if (!string.IsNullOrEmpty(delayimagemin.Text) && NumberHelper.ValidateNumber(delayimagemin.Text)) { mindelay = Convert.ToInt32(delayimagemin.Text); } if (!string.IsNullOrEmpty(imagedelaymax.Text) && NumberHelper.ValidateNumber(imagedelaymax.Text)) { maxdelay = Convert.ToInt32(imagedelaymax.Text); } lock (_lockObject) { int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay); AddTophotoLogger("[ " + DateTime.Now + " ] => [ Delay For " + delay + " Seconds ]"); Thread.Sleep(delay *1000); } if (lstCountImage.Count >= ClGlobul.countNOOfFollowersandImageDownload) { return; } try { } catch { } } } } catch { } } #region pagination string pageLink = string.Empty; while (true) { //if (stopScrapImageBool) return; string startString = "<a href=\""; string endString = "\" class=\"mainimg\""; string imageId = string.Empty; string imageSrc = string.Empty; if (!string.IsNullOrEmpty(pageLink)) { pageSource = objGlobusHttpHelper.getHtmlfromUrl(new Uri(pageLink),""); if (string.IsNullOrEmpty(pageSource)) { pageSource = objGlobusHttpHelper.getHtmlfromUrl(new Uri(pageLink),""); } } if (pageSource.Contains("<ul class=\"pager\">") && pageSource.Contains("rel=\"next\">")) { try { pageLink = getBetween(pageSource, "<ul class=\"pager\">", "rel=\"next\">"); } catch { } if (!string.IsNullOrEmpty(pageLink)) { try { int len = pageLink.IndexOf("<a href=\""); len = len + ("<a href=\"").Length; pageLink = pageLink.Substring(len); pageLink = pageLink.Trim(); pageLink = pageLink.TrimEnd(new char[] { '"' }); pageLink = "http://websta.me/" + pageLink; } catch { } if (!string.IsNullOrEmpty(pageLink)) { string response = string.Empty; try { response = objGlobusHttpHelper.getHtmlfromUrl(new Uri(pageLink),""); } catch { } if (!string.IsNullOrEmpty(response)) { if (response.Contains("<div class=\"mainimg_wrapper\">")) { try { string[] arr1 = Regex.Split(response, "<div class=\"mainimg_wrapper\">"); if (arr1.Length > 1) { arr1 = arr1.Skip(1).ToArray(); foreach (string items in arr1) { try { //if (stopScrapImageBool) return; if (items.Contains("<a href=\"/p/")) { int indexStart = items.IndexOf("<a href=\"/p/"); string itemarrNow = items.Substring(indexStart); try { imageId = getBetween(itemarrNow, startString, endString).Replace("/", ""); } catch { } if (!string.IsNullOrEmpty(imageId)) { //counter++; //imageId = "http://websta.me"+imageId; } if (itemarrNow.Contains("<img src=\"")) { try { imageSrc = getBetween(itemarrNow, "<img src=\"", "\""); } catch { } } counter++; { SaveImageWithUrl(imageSrc, FileData, imageId + "_" + counter); } lstCountImage.Add(imageSrc); lstCountImage = lstCountImage.Distinct().ToList(); //AddTophotoLogger("Image DownLoaded with ImageName " + imageId + "_" + counter); AddTophotoLogger("[ " + DateTime.Now + " ] =>[Image DownLoaded with ImageName " + imageId + "_" + counter); if (!string.IsNullOrEmpty(delayimagemin.Text) && NumberHelper.ValidateNumber(delayimagemin.Text)) { mindelay = Convert.ToInt32(delayimagemin.Text); } if (!string.IsNullOrEmpty(imagedelaymax.Text) && NumberHelper.ValidateNumber(imagedelaymax.Text)) { maxdelay = Convert.ToInt32(imagedelaymax.Text); } lock (_lockObject) { int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay); AddToLogger("[ " + DateTime.Now + " ] => [ Delay For " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); } if (lstCountImage.Count >= ClGlobul.countNOOfFollowersandImageDownload) { return; } } } catch { } } if (lstCountImage.Count >= ClGlobul.countNOOfFollowersandImageDownload) { return; } } } catch { } } } else { } } else { break; } } else { break; } } else { break; } } #endregion } } } if (!string.IsNullOrEmpty(pageSource)) { url = mainUrl + "n/" + itemImageTag; AddTophotoLogger("[ " + DateTime.Now + " ] =>[" + itemImageTag + " = Username is Private, so unable to fetch Image "); } else { AddTophotoLogger("[ " + DateTime.Now + " ] =>[" + itemImageTag + " = This user does not exist."); } //else //{ // AddToLogger("[ " + DateTime.Now + " ] => [ No Image found.]"); // //return; //} }
private void startProcessUsingHashTag() { try { GloBoardPro.HasTagListListThread.Add(Thread.CurrentThread); GloBoardPro.HasTagListListThread.Distinct(); Thread.CurrentThread.IsBackground = true; } catch { } int parsedValue; bool ProcessStartORnot = false; AddToHashLoggerDAta("[ " + DateTime.Now + " ] => [Pleasewait ]"); List<List<string>> list_Accounts = new List<List<string>>(); acc_checker_counter = DemoStagramPro.ClGlobul.accountList.Count(); list_Accounts = ListUtilities.Split(DemoStagramPro.ClGlobul.accountList, Maxthread); ThreadPool.SetMaxThreads(Noofthreads, 5); GlobDramProHttpHelper httphelper = new GlobDramProHttpHelper(); HashTag objHashTag = new HashTag(); List<string> Usercount = new List<string>(); try { if (!(string.IsNullOrEmpty(txtHashTagDelay.Text))) { ClGlobul.hashTagDelay = Convert.ToInt32(txtHashTagDelay.Text); } else { ClGlobul.hashTagDelay = 10; } } catch { } if (chkDivideDataFollow1.Checked && rdbDivideGivenByUser1.Checked) { if (!int.TryParse(txtDiveideByUser1.Text, out parsedValue)) { AddToLogger("[ " + DateTime.Now + " ] => [ This is a number only field.Please enter proper value in divide given by user field. ]"); return; } } try { if (ClGlobul.HashFollower.Count != 0) { if (!string.IsNullOrEmpty(txtNumberProfilesFollow.Text)) { ClGlobul.NumberOfProfilesToFollow = Convert.ToInt32(txtNumberProfilesFollow.Text); //ClGlobul.SnapVideosCounterfollow = Convert.ToInt32(txtNumberProfilesFollow.Text) * ClGlobul.HashFollower.Count; } else { MessageBox.Show("Please enter the numbers of profiles to follow and continue."); AddToHashLoggerDAta("[ " + DateTime.Now + "] " + "[ Please enter the numbers of profiles to follow and continue. ]"); return; } } if (ClGlobul.HashLiker.Count != 0) { if (!string.IsNullOrEmpty(txtNumberPicsVideosLike.Text)) { ClGlobul.NumberofSnapsVideosToLike = Convert.ToInt32(txtNumberPicsVideosLike.Text); //ClGlobul.SnapVideosCounter = Convert.ToInt32(txtNumberPicsVideosLike.Text) * ClGlobul.HashLiker.Count; } else { MessageBox.Show("Please enter the numbers of snaps or videos to like and continue."); AddToHashLoggerDAta("[ " + DateTime.Now + "] " + "[ Please enter the numbers of snaps or videos to like and continue. ]"); return; } } if (ClGlobul.HashComment.Count != 0) { if (!string.IsNullOrEmpty(txtNumberSnapsVideosComment.Text)) { ClGlobul.NumberofSnapsVideosToComment = Convert.ToInt32(txtNumberSnapsVideosComment.Text); // ClGlobul.SnapVideosCounterComment = Convert.ToInt32(txtNumberSnapsVideosComment.Text) * ClGlobul.HashComment.Count; } else { MessageBox.Show("Please enter the numbers of snaps or videos to like and continue."); AddToHashLoggerDAta("[ " + DateTime.Now + "] " + "[ Please enter the numbers of snaps or videos to like and continue. ]"); return; } } } catch (Exception ex) { } #region scrapHashTagFollowr List<string> lstHashTagUserIdTemp = new List<string>(); List<string> lstHashTagUserId = new List<string>(); if (!string.IsNullOrEmpty(txtHashFollower.Text.Trim())) { foreach (string hashKeyword in ClGlobul.HashFollower) { AddToHashLoggerDAta("[ " + DateTime.Now + "] " + "[ Scraping Users with HashTag " + hashKeyword + "]"); lstHashTagUserIdTemp = GetUser(hashKeyword); lstHashTagUserId.AddRange(lstHashTagUserIdTemp); AddToHashLoggerDAta("[ " + DateTime.Now + "] " + "[ Scraped Users with HashTag " + hashKeyword + "]"); } } #endregion #region ScraperhashLiker List<string> lstHashTagUserIdLikeTemp = new List<string>(); List<string> lstHashLikeTagUserLikeId = new List<string>(); if (!string.IsNullOrEmpty(txtHashLike.Text.Trim())) { foreach (string hashLikerKeyword in ClGlobul.HashLiker) { AddToHashLoggerDAta("[ " + DateTime.Now + "] " + "[ Scraping PhotoId with HashTag " + hashLikerKeyword + "]"); lstHashTagUserIdLikeTemp = GetPhotoId(hashLikerKeyword); lstHashLikeTagUserLikeId.AddRange(lstHashTagUserIdLikeTemp); AddToHashLoggerDAta("[ " + DateTime.Now + "] " + "[ Scraped Users with HashTag " + hashLikerKeyword + "]"); } } #endregion #region hashtagcomment List<string> lstHashTagUserIdCommentTemp = new List<string>(); List<string> lstHashTagCommentUserId = new List<string>(); if (!string.IsNullOrEmpty(txtHashComment.Text.Trim())) { foreach (string hashCommentKeyword in ClGlobul.HashComment) { AddToHashLoggerDAta("[ " + DateTime.Now + "] " + "[ Scraping Users PhotoId HashTag " + hashCommentKeyword + "]"); lstHashTagUserIdCommentTemp = GetPhotoId1(hashCommentKeyword); lstHashTagCommentUserId.AddRange(lstHashTagUserIdCommentTemp); AddToHashLoggerDAta("[ " + DateTime.Now + "] " + "[ Scraped Users PhotoId HashTag " + hashCommentKeyword + "]"); } } #endregion List<List<string>> list_lstTargetUsers = new List<List<string>>(); counter_follow = DemoStagramPro.ClGlobul.accountList.Count(); list_Accounts = ListUtilities.Split(DemoStagramPro.ClGlobul.accountList, Maxthread); List<List<string>> list_lstTargetHashTag = new List<List<string>>(); List<List<string>> list_lstTargetHashTagLike = new List<List<string>>(); List<List<string>> list_lstTargetHashTagComment = new List<List<string>>(); //for divide by data logic here if (chkDivideDataFollow1.Checked) { if (rdbDivideGivenByUser1.Checked || rdbDivideEqually1.Checked) { int splitNo = 0; if (rdbDivideEqually1.Checked) { splitNo = lstHashTagUserId.Count / ClGlobul.accountList.Count; } else if (rdbDivideGivenByUser1.Checked) { if (Convert.ToInt32(txtDiveideByUser1.Text.Trim()) != 0) { int res = Convert.ToInt32(Convert.ToInt32(txtDiveideByUser1.Text.Trim())); splitNo = res; } } if (splitNo == 0) { splitNo = RandomNumberGenerator.GenerateRandom(0, lstHashTagUserId.Count - 1); } list_lstTargetHashTag = Split(lstHashTagUserId, splitNo); } } if (chkDivideDataFollow1.Checked) { if (rdbDivideGivenByUser1.Checked || rdbDivideEqually1.Checked) { int splitNo = 0; if (rdbDivideEqually1.Checked) { splitNo = lstHashLikeTagUserLikeId.Count / ClGlobul.accountList.Count; } else if (rdbDivideGivenByUser1.Checked) { if (Convert.ToInt32(txtDiveideByUser1.Text.Trim()) != 0) { int res = Convert.ToInt32(Convert.ToInt32(txtDiveideByUser1.Text.Trim())); splitNo = res; } } if (splitNo == 0) { splitNo = RandomNumberGenerator.GenerateRandom(0, lstHashLikeTagUserLikeId.Count - 1); } list_lstTargetHashTagLike = Split(lstHashLikeTagUserLikeId, splitNo); } } if (chkDivideDataFollow1.Checked) { if (rdbDivideGivenByUser1.Checked || rdbDivideEqually1.Checked) { int splitNo = 0; if (rdbDivideEqually1.Checked) { splitNo = lstHashTagCommentUserId.Count / ClGlobul.accountList.Count; } else if (rdbDivideGivenByUser1.Checked) { if (Convert.ToInt32(txtDiveideByUser1.Text.Trim()) != 0) { int res = Convert.ToInt32(Convert.ToInt32(txtDiveideByUser1.Text.Trim())); splitNo = res; } } if (splitNo == 0) { splitNo = RandomNumberGenerator.GenerateRandom(0, lstHashTagCommentUserId.Count - 1); } list_lstTargetHashTagComment = Split(lstHashTagCommentUserId, splitNo); } } int LstCounter = 0; // unlikeCompletionCount = ClGlobul.accountList.Count; unlikeCompletionLikeCount = ClGlobul.accountList.Count; try { if (list_Accounts.Count == 0) { AddToHashLoggerDAta("[ " + DateTime.Now + "] " + "[ Please upload account. ]"); return; } else { ClGlobul.countNoOFAccountHashFollower = ClGlobul.accountList.Count; ClGlobul.countNoOFAccountHashComment = ClGlobul.accountList.Count; ClGlobul.countNOOfFollowersandImageDownload = ClGlobul.accountList.Count; //try //{ // ClGlobul.SnapVideosCounterfollow = ClGlobul.SnapVideosCounterfollow * list_Accounts.Count; //} //catch { }; //try //{ // ClGlobul.SnapVideosCounter = ClGlobul.SnapVideosCounter * list_Accounts.Count; //} //catch { }; //try //{ // ClGlobul.SnapVideosCounterComment = ClGlobul.SnapVideosCounterComment * list_Accounts.Count; //} //catch { }; foreach (List<string> listAccounts in list_Accounts) { foreach (string val in listAccounts) { //soniaghezzo94:mdag123456:93.118.68.148:3128 string[] StrArrar = Regex.Split(val, ":"); string account = string.Empty; string pass = string.Empty; string proxyadd = string.Empty; string proxyport = string.Empty; string proxyUser = string.Empty; string proxyPass = string.Empty; try { account = StrArrar[0]; } catch { account = StrArrar[0]; } try { pass = StrArrar[1]; } catch { pass = StrArrar[1]; } try { proxyadd = StrArrar[2]; } catch { proxyadd = StrArrar[2]; } try { proxyport = StrArrar[3]; } catch { proxyport = StrArrar[3]; } try { proxyUser = StrArrar[4]; } catch { proxyUser = StrArrar[4]; } try { proxyPass = StrArrar[5]; } catch { proxyPass = StrArrar[5]; } string txtUrl = txtHashFollower.Text; string txtLikeComment = txtHashLike.Text; if (LstCounter == list_lstTargetHashTag.Count && (chkDivideDataFollow1.Checked)) { //AddToLogger("[ " + DateTime.Now + " ] => [ Account is grater than List of users. ]"); // break; } List<string> list_lstTargetHashTag_item = new List<string>(); try { if (chkDivideDataFollow1.Checked) { list_lstTargetHashTag_item = list_lstTargetHashTag[LstCounter]; } else { list_lstTargetHashTag_item = lstHashTagUserId; } } catch { } List<string> list_lstTargetHashTagLike_item = new List<string>(); try { if (chkDivideDataFollow1.Checked) { list_lstTargetHashTagLike_item = list_lstTargetHashTagLike[LstCounter]; } else { list_lstTargetHashTagLike_item = lstHashLikeTagUserLikeId; } } catch { } List<string> list_lstTargetHashTagComment_item = new List<string>(); try { if (chkDivideDataFollow1.Checked) { list_lstTargetHashTagComment_item = list_lstTargetHashTagComment[LstCounter]; } else { list_lstTargetHashTagComment_item = lstHashTagCommentUserId; } } catch { } InstagramManager.Classes.InstagramAccountManager InstagramAccountManager = new InstagramManager.Classes.InstagramAccountManager(account, pass, proxyadd, proxyport, proxyUser, proxyPass); string status = InstagramAccountManager.LoginNew(ref InstagramAccountManager.httpHelper); if (!status.Contains("Success")) { status = InstagramAccountManager.LoginNew(ref InstagramAccountManager.httpHelper); } AddToHashLoggerDAta("[ " + DateTime.Now + "] " + "[ Logged in with account : " + InstagramAccountManager.Username + " ]"); // string ddd = Uri.EscapeDataString(txtUrl); try { if (ClGlobul.HashFollower.Count != 0) { //foreach (string hashTagFollow in ClGlobul.HashFollower) //commented for divide data //foreach (string hashTagFollow in list_lstTargetHashTag_item) { new Thread(() => { try { GloBoardPro.HasTagListListThread.Add(Thread.CurrentThread); GloBoardPro.HasTagListListThread.Distinct(); Thread.CurrentThread.IsBackground = true; } catch { } objHashTag.HashTagFollow(ref InstagramAccountManager, list_lstTargetHashTag_item); }).Start(); } } if (ClGlobul.HashLiker.Count != 0) { //foreach (string hashTagLike in ClGlobul.HashLiker) { new Thread(() => { // objHashTag.HashTagLike(ref InstagramAccountManager, hashTagLike); objHashTag.HashTagLike(ref InstagramAccountManager, list_lstTargetHashTagLike_item); }).Start(); } } if (ClGlobul.HashComment.Count != 0) { //foreach (string hashTagComment in ClGlobul.HashComment) { new Thread(() => { objHashTag.HashTagComment(ref InstagramAccountManager, list_lstTargetHashTagComment_item); }).Start(); } } } catch (Exception ex) { } LstCounter++; Thread.Sleep(1000); } } } } catch (Exception ex) { } finally { { if (unlikeCompletionLikeCount == 0) { } } } }
public List<string> GetPhotoId1(string hashTag) { try { GloBoardPro.HasTagListListThread.Add(Thread.CurrentThread); GloBoardPro.HasTagListListThread.Distinct(); Thread.CurrentThread.IsBackground = true; } catch { } //string url = "http://websta.me/" + "tag/" + hashTag; string url = "http://websta.me/" + "tag/" + hashTag.Replace("%23", "").Replace("#", ""); GlobDramProHttpHelper objInstagramUser = new GlobDramProHttpHelper(); List<string> lstPhotoId = new List<string>(); string pageSource = objInstagramUser.getHtmlfromUrl(new Uri(url),""); if (string.IsNullOrEmpty(pageSource)) { pageSource = objInstagramUser.getHtmlfromUrl(new Uri(url),""); } if (!string.IsNullOrEmpty(pageSource)) { if (pageSource.Contains("<div class=\"mainimg_wrapper\">")) { string[] arr = Regex.Split(pageSource, "<div class=\"mainimg_wrapper\">"); if (arr.Length > 1) { arr = arr.Skip(1).ToArray(); foreach (string itemarr in arr) { try { string startString = "<a href=\"/p/"; string endString = "\" class=\"mainimg\""; string imageId = string.Empty; string imageSrc = string.Empty; if (itemarr.Contains("<a href=\"/p/")) { int indexStart = itemarr.IndexOf("<a href=\"/p/"); string itemarrNow = itemarr.Substring(indexStart); if (itemarrNow.Contains(startString) && itemarrNow.Contains(endString)) { try { imageId = getBetween(itemarrNow, startString, endString).Replace("/", ""); } catch { } if (!string.IsNullOrEmpty(imageId)) { lstPhotoId.Add(imageId); lstPhotoId.Distinct(); if (lstPhotoId.Count >= ClGlobul.NumberofSnapsVideosToComment) { return lstPhotoId; } //imageId = "http://websta.me"+imageId; } } } } catch (Exception ex) { } } #region pagination string pageLink = string.Empty; while (true) { try { GloBoardPro.HasTagListListThread.Add(Thread.CurrentThread); GloBoardPro.HasTagListListThread.Distinct(); Thread.CurrentThread.IsBackground = true; } catch { } //if (stopScrapImageBool) return; string startString = "<a href=\"/p/"; string endString = "\" class=\"mainimg\""; string imageId = string.Empty; string imageSrc = string.Empty; if (!string.IsNullOrEmpty(pageLink)) { pageSource = objInstagramUser.getHtmlfromUrl(new Uri(pageLink),""); } if (pageSource.Contains("<ul class=\"pager\">") && pageSource.Contains("rel=\"next\">")) { try { pageLink = getBetween(pageSource, "<ul class=\"pager\">", "rel=\"next\">"); } catch { } if (!string.IsNullOrEmpty(pageLink)) { try { int len = pageLink.IndexOf("<a href=\""); len = len + ("<a href=\"").Length; pageLink = pageLink.Substring(len); pageLink = pageLink.Trim(); pageLink = pageLink.TrimEnd(new char[] { '"' }); pageLink = "http://websta.me/" + pageLink; } catch { } if (!string.IsNullOrEmpty(pageLink)) { string response = string.Empty; try { response = objInstagramUser.getHtmlfromUrl(new Uri(pageLink),""); } catch { } if (!string.IsNullOrEmpty(response)) { if (response.Contains("<div class=\"mainimg_wrapper\">")) { try { string[] arr1 = Regex.Split(response, "<div class=\"mainimg_wrapper\">"); if (arr1.Length > 1) { arr1 = arr1.Skip(1).ToArray(); foreach (string items in arr1) { try { //if (stopScrapImageBool) return; if (items.Contains("<a href=\"/p/")) { int indexStart = items.IndexOf("<a href=\"/p/"); string itemarrNow = items.Substring(indexStart); try { imageId = getBetween(itemarrNow, startString, endString).Replace("/", ""); } catch { } if (!string.IsNullOrEmpty(imageId)) { lstPhotoId.Add(imageId); lstPhotoId.Distinct(); if (lstPhotoId.Count >= ClGlobul.NumberofSnapsVideosToComment) { return lstPhotoId; } //imageId = "http://websta.me"+imageId; } //counter++; //Addtologger("Image DownLoaded with ImageName "+imageId+"_"+counter); if (lstPhotoId.Count >= ClGlobul.NumberofSnapsVideosToComment) { return lstPhotoId; } } } catch { } } if (lstPhotoId.Count >= ClGlobul.NumberofSnapsVideosToComment) { return lstPhotoId; } } } catch { } } } else { } } else { break; } } else { break; } } else { break; } } #endregion } } } return lstPhotoId; }
public List<string> GetUser(string hashTag) { List<string> lstUser = new List<string>(); try { string url = "http://websta.me/search/" + hashTag.Replace("#", "%23"); GlobDramProHttpHelper objInstagramUser = new GlobDramProHttpHelper(); string pageSource = objInstagramUser.getHtmlfromUrl(new Uri(url),""); if (string.IsNullOrEmpty(pageSource)) { pageSource = objInstagramUser.getHtmlfromUrl(new Uri(url),""); } if (!string.IsNullOrEmpty(pageSource)) { if (pageSource.Contains("username\" href=")) { string ScrapUser = string.Empty; string[] arr = Regex.Split(pageSource, "username\" href="); if (arr.Length > 1) { arr = arr.Skip(1).ToArray(); foreach (string itemarr in arr) { try { if (itemarr.Contains("<a href=")) { ScrapUser = getBetween(itemarr, "", "</a>"); string[] urldata = Regex.Split(ScrapUser, ">"); string username = urldata[1]; if (!string.IsNullOrEmpty(username)) { lstUser.Add(username); lstUser = lstUser.Distinct().ToList(); if (lstUser.Count >= ClGlobul.NumberOfProfilesToFollow) { return lstUser; } } } } catch { } } } } } } catch (Exception ex) { Console.Write(ex.Message); } return lstUser; }
public void getpageSourceFromProxy(object item) { if (proxyStop) return; try { Thread.CurrentThread.IsBackground = true; lstProxyThread.Add(Thread.CurrentThread); lstProxyThread = lstProxyThread.Distinct().ToList(); } catch { } Array Item_value = (Array)item; string ClGlobul_ProxyList_item = (string)Item_value.GetValue(0); DemoStagramPro.frm_stagram frm1 = new DemoStagramPro.frm_stagram(); Globussoft.GlobDramProHttpHelper GlobusHttpHelper = new Globussoft.GlobDramProHttpHelper(); string proxyad = string.Empty; string proxyport = string.Empty; string proxyusername = string.Empty; string proxyPassword = string.Empty; string pagesource1 = string.Empty; string pagesource = string.Empty; try { string[] proxyLst = ClGlobul_ProxyList_item.Split(':'); if (proxyLst.Count() > 3) { proxyad = proxyLst[2]; proxyport = proxyLst[3]; //proxyusername = proxyLst[2]; //proxyPassword = proxyLst[3]; } else if (proxyLst.Count() > 0 && proxyLst.Count() < 3) { proxyad = proxyLst[0]; proxyport = proxyLst[1]; } else { return; } try { if (proxyStop) return; //pagesource1 = GlobusHttpHelper.getHtmlfromUrlProxy(new Uri("http://websta.me/login"), proxyad, Convert.ToInt16(proxyport), proxyusername, proxyPassword); pagesource1 = GlobusHttpHelper.getHtmlfromUrlProxy(new Uri("http://web.stagram.com/"), proxyad, Convert.ToInt16(proxyport), proxyusername, proxyPassword); } catch { }; if (string.IsNullOrEmpty(pagesource1)) { pagesource1 = string.Empty; pagesource1 = GlobusHttpHelper.getHtmlfromUrlProxy(new Uri("http://web.stagram.com/"), proxyad, Convert.ToInt16(proxyport), proxyusername, proxyPassword); } if (!string.IsNullOrEmpty(pagesource1)) { if (proxyStop) return; addInFinalCheckedProxyist(proxyad, proxyport, proxyusername, proxyPassword, pagesource1); } else { if (proxyStop) return; AddToLogger("[ " + DateTime.Now + " ] => [ Proxy Is not Working : " + proxyad + ":" + proxyport + ":" + proxyusername + ":" + proxyPassword + " ]"); lock (lockerforNonWorkingProxies) { GramBoardProFileHelper.AppendStringToTextfileNewLine(proxyad + ":" + proxyport + ":" + proxyusername + ":" + proxyPassword, GramBoardProFileHelper.NonWorkingProxiesList); } } } catch (Exception) { if (proxyStop) return; AddToLogger("[ " + DateTime.Now + " ] => [ Proxy Is not Working : " + proxyad + ":" + proxyport + ":" + proxyusername + ":" + proxyPassword + " ]"); lock (lockerforNonWorkingProxies) { GramBoardProFileHelper.AppendStringToTextfileNewLine(proxyad + ":" + proxyport + ":" + proxyusername + ":" + proxyPassword, GramBoardProFileHelper.NonWorkingProxiesList); } } finally { } }
public void getloginForComment(object Accounts) { string proxyadd = string.Empty; string proxyport = string.Empty; string proxyUser = string.Empty; string proxyPass = string.Empty; string account = string.Empty; string pass = string.Empty; InstagramManager.Classes.InstagramAccountManager InstagramAccountManager = new InstagramManager.Classes.InstagramAccountManager(account, pass, proxyadd, proxyport, proxyUser, proxyPass); try { if (!CommentIstrueOrFals) { try { Lst_Commentthread.Add(Thread.CurrentThread); Lst_Commentthread = Lst_Commentthread.Distinct().ToList(); Thread.CurrentThread.IsBackground = true; } catch (Exception ex) { GramBoardProFileHelper.AppendStringToTextfileNewLine("-----------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForComment); GramBoardProFileHelper.AppendStringToTextfileNewLine(DateTime.Now + ":=> Methode Name => getloginForComment :=> " + ex.Message, GramBoardProFileHelper.ErrorLogFilePathForComment); GramBoardProFileHelper.AppendStringToTextfileNewLine("-----------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForComment); } Array accountinfo = (Array)Accounts; account = (string)accountinfo.GetValue(0); pass = (string)accountinfo.GetValue(1); string ProxyValue = (string)accountinfo.GetValue(2); string[] proxyarray = null; if (!string.IsNullOrEmpty(ProxyValue)) { proxyarray = ProxyValue.Split(':'); if (proxyarray.Count() > 2) { proxyadd = proxyarray[0]; proxyport = proxyarray[1]; proxyUser = proxyarray[2]; proxyPass = proxyarray[3]; } else { proxyadd = proxyarray[0]; proxyport = proxyarray[1]; } } try { //string proxyadd = string.Empty; //string proxyport = string.Empty; //string proxyUser = string.Empty; //string proxyPass = string.Empty; InstagramAccountManager = new InstagramManager.Classes.InstagramAccountManager(account, pass, proxyadd, proxyport, proxyUser, proxyPass); #region My Code GlobDramProHttpHelper _GlobusHttpHelper = new GlobDramProHttpHelper(); #endregion InstagramAccountManager.logEvents.addToLogger += new EventHandler(logEvents_addToLogger); ///Get login from account.... //string statuse = InstagramAccountManager.Login(); //string statuse = InstagramAccountManager.MyLogin(ref _GlobusHttpHelper); string statuse = InstagramAccountManager.MyLoginandComment(ref InstagramAccountManager.httpHelper, "", "", ""); if (InstagramAccountManager.LoggedIn == true) { //get comment from Login account .... AddToCommentLogger("[ " + DateTime.Now + " ] => [ Logged in With " + account + " ]"); AddToCommentLogger("[ " + DateTime.Now + " ] => [ Starting Comment with " + account + " ]"); foreach (var CommentIdsForMSG_item in ClGlobul.CommentIdsForMSG) { getComment(ref InstagramAccountManager, CommentIdsForMSG_item); } } else if (statuse.Contains("Failed")) { AddToCommentLogger("[ " + DateTime.Now + " ] => [ Login Failed For " + account + " ]"); } else if (statuse.Contains("AccessIssue")) { AddToCommentLogger("[ " + DateTime.Now + " ] => [ Login Failed For " + account + " ]"); } else if (statuse.Contains("Stream was not readable.")) { //proxy is currect but have some login issues AddToCommentLogger("[ " + DateTime.Now + " ] => [ Stream was not readable. ]"); try { string removeingProxy = ClGlobul.finalProxyList.Where(e => e.Contains(proxyarray[0])).ToArray()[0]; ClGlobul.finalProxyList.Remove(removeingProxy); } catch (Exception ex) { GramBoardProFileHelper.AppendStringToTextfileNewLine("-----------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForComment); GramBoardProFileHelper.AppendStringToTextfileNewLine(DateTime.Now + ":=> Methode Name => getloginForComment :=> " + ex.Message, GramBoardProFileHelper.ErrorLogFilePathForComment); GramBoardProFileHelper.AppendStringToTextfileNewLine("-----------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForComment); }; } else if (statuse.Contains("The request was aborted: The operation has timed out.")) { //proxy is currect but request time out //AddToCommentLogger("The request was aborted: The operation has timed out."); AddToCommentLogger("[ " + DateTime.Now + " ] => [ Login Failed For " + account + " ]"); } else if (statuse.Contains("503")) { //some request problem AddToCommentLogger("[ " + DateTime.Now + " ] => [ Login Failed For " + account + " ]"); //AddToCommentLogger("503 some request problem /Server unavailable."); } else if (statuse.Contains("403")) { AddToCommentLogger("[ " + DateTime.Now + " ] => [ Login Failed For " + account + " ]"); //AddToCommentLogger("403"); } else { AddToCommentLogger("[ " + DateTime.Now + " ] => [ Login Failed For " + account + " ]"); } } catch (Exception ex) { //AddTophotoLogger("[ " + DateTime.Now + " ] => [ " + account + " is not login Error : GetLoginForComment (1) => MSG :" + ex.Message + " ]"); GramBoardProFileHelper.AppendStringToTextfileNewLine("-----------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForComment); GramBoardProFileHelper.AppendStringToTextfileNewLine(DateTime.Now + ":=> Methode Name => GetLoginForComment (1):=> " + ex.Message, GramBoardProFileHelper.ErrorLogFilePathForComment); GramBoardProFileHelper.AppendStringToTextfileNewLine("-----------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForComment); } finally { InstagramAccountManager.logEvents.addToLogger -= new EventHandler(logEvents_addToLogger); } } } catch (Exception ex) { //AddTophotoLogger(DateTime.Now + ":=> Methode Name => GetLoginForComment (2) :=> " + ex.Message); GramBoardProFileHelper.AppendStringToTextfileNewLine("-----------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForComment); GramBoardProFileHelper.AppendStringToTextfileNewLine(DateTime.Now + ":=> Methode Name => GetLoginForComment (2) :=> " + ex.Message, GramBoardProFileHelper.ErrorLogFilePathForComment); GramBoardProFileHelper.AppendStringToTextfileNewLine("-----------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForComment); } finally { count_ThreadControllerForComment--; lock (lockr_ThreadControllerForComment) { if (!CommentIstrueOrFals) { Monitor.Pulse(lockr_ThreadControllerForComment); } } counter_comment--; if (counter_comment == 0) { AddToCommentLogger("----------------------------------------------------------------------------------------------------------------------------------"); AddToCommentLogger("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]"); AddToCommentLogger("----------------------------------------------------------------------------------------------------------------------------------"); } } }
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 ]"); }
public string postFormDataForFollowUserNew(Uri url, string postData, string Referes, NameValueCollection nameValueCollection,string user,string pass) { GlobDramProHttpHelper _GlobusHttpHelper = new GlobDramProHttpHelper(); string Username = user; string Password = pass; string firstUrl = "https://api.instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes"; //https://instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes string secondURL = "https://instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes"; string res_secondURL = _GlobusHttpHelper.getHtmlfromUrlProxy(new Uri(secondURL), proxyAddress, 80, proxyUsername, proxyPassword); string nextUrl = "https://instagram.com/accounts/login/?force_classic_login=&next=/oauth/authorize/%3Fclient_id%3D9d836570317f4c18bca0db6d2ac38e29%26redirect_uri%3Dhttp%3A//websta.me/%26response_type%3Dcode%26scope%3Dcomments%2Brelationships%2Blikes"; string res_nextUrl = _GlobusHttpHelper.getHtmlfromUrlProxy(new Uri(nextUrl), proxyAddress, 80, proxyUsername, proxyPassword); #region << Get Token >> //Get Token Number of Id int FirstPointToken_nextUrl = res_nextUrl.IndexOf("csrfmiddlewaretoken"); string FirstTokenSubString_nextUrl = res_nextUrl.Substring(FirstPointToken_nextUrl); int SecondPointToken_nextUrl = FirstTokenSubString_nextUrl.IndexOf("/>"); string Token = FirstTokenSubString_nextUrl.Substring(0, SecondPointToken_nextUrl).Replace("csrfmiddlewaretoken", string.Empty).Replace("value=", string.Empty).Replace("\"", string.Empty).Replace("'", string.Empty).Trim(); #endregion string login = "******"; string postdata_Login = "******" + Token + "&username="******"&password="******""; string res_postdata_Login = _GlobusHttpHelper.postFormData(new Uri(login), postdata_Login, login, ""); gRequest = (HttpWebRequest)WebRequest.Create(url); //gRequest.ServicePoint.Expect100Continue = false; gRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36"; gRequest.Accept = "application/json, text/javascript, */*; q=0.01"; gRequest.CookieContainer = new CookieContainer();// gCookiesContainer; gRequest.Method = "POST"; gRequest.KeepAlive = true; gRequest.ContentType = @"application/x-www-form-urlencoded; charset=UTF-8"; gRequest.Headers["Accept-Language"] = "en-us,en;q=0.5"; gRequest.Headers["X-Requested-With"] = "XMLHttpRequest"; gRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; if (!string.IsNullOrEmpty(Referes)) { gRequest.Referer = Referes; } try { if (nameValueCollection != null) { foreach (string item in nameValueCollection.Keys) { gRequest.Headers.Add(item, nameValueCollection[item]); } } } catch (Exception) { } ///Modified BySumit 18-11-2011 ChangeProxy(proxyAddress, port, proxyUsername, proxyPassword); #region CookieManagement if (this.gCookies != null && this.gCookies.Count > 0) { setExpect100Continue(); gRequest.CookieContainer.Add(gCookies); } //logic to postdata to the form try { setExpect100Continue(); string postdata = string.Format(postData); byte[] postBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(postData); gRequest.ContentLength = postBuffer.Length; Stream postDataStream = gRequest.GetRequestStream(); postDataStream.Write(postBuffer, 0, postBuffer.Length); postDataStream.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); // //Logger.LogText("Internet Connectivity Exception : "+ ex.Message,null); } //post data logic ends //Get Response for this request url string html; try { gResponse = (HttpWebResponse)gRequest.GetResponse(); } catch (WebException ex) { Console.WriteLine(ex.Message); // //Logger.LogText("Response from " + url + ":" + ex.Message, null); } //check if the status code is http 200 or http ok if (gResponse.StatusCode == HttpStatusCode.OK) { //get all the cookies from the current request and add them to the response object cookies setExpect100Continue(); gResponse.Cookies = gRequest.CookieContainer.GetCookies(gRequest.RequestUri); //check if response object has any cookies or not //Added by sandeep pathak //gCookiesContainer = gRequest.CookieContainer; if (gResponse.Cookies.Count > 0) { //check if this is the first request/response, if this is the response of first request gCookies //will be null if (this.gCookies == null) { gCookies = gResponse.Cookies; } else { foreach (Cookie oRespCookie in gResponse.Cookies) { bool bMatch = false; foreach (Cookie oReqCookie in this.gCookies) { if (oReqCookie.Name == oRespCookie.Name) { oReqCookie.Value = oRespCookie.Value; bMatch = true; break; // } } if (!bMatch) this.gCookies.Add(oRespCookie); } } } #endregion StreamReader reader = new StreamReader(gResponse.GetResponseStream()); string responseString = reader.ReadToEnd(); reader.Close(); //Console.Write("Response String:" + responseString); return responseString; } else { return "Error in posting data"; } }
public void getpageSourceFromProxy(object item) { if (proxyStop) return; try { Thread.CurrentThread.IsBackground = true; lstProxyThread.Add(Thread.CurrentThread); lstProxyThread = lstProxyThread.Distinct().ToList(); } catch { } countParseProxiesThreads++; Array Item_value = (Array)item; string ClGlobul_ProxyList_item = (string)Item_value.GetValue(0); DemoStagramPro.frm_stagram frm1 = new DemoStagramPro.frm_stagram(); Globussoft.GlobDramProHttpHelper GlobusHttpHelper = new Globussoft.GlobDramProHttpHelper(); ChilkatHttpHelpr objchilkat = new ChilkatHttpHelpr(); string proxyad = string.Empty; string proxyport = string.Empty; string proxyusername = string.Empty; string proxyPassword = string.Empty; string pagesource1 = string.Empty; string pagesource = string.Empty; try { string[] proxyLst = ClGlobul_ProxyList_item.Split(':'); if (proxyLst.Count() > 3) { proxyad = proxyLst[0]; proxyport = proxyLst[1]; proxyusername = proxyLst[2]; proxyPassword = proxyLst[3]; } else if (proxyLst.Count() > 0 && proxyLst.Count() < 3) { proxyad = proxyLst[0]; proxyport = proxyLst[1]; } else { return; } try { if (proxyStop) return; //pagesource1 = GlobusHttpHelper.getHtmlfromUrlProxy(new Uri("http://websta.me/login"), proxyad, Convert.ToInt16(proxyport), proxyusername, proxyPassword); pagesource1 = GlobusHttpHelper.getHtmlfromUrlProxy(new Uri("http://web.stagram.com/"), proxyad, Convert.ToInt16(proxyport), proxyusername, proxyPassword); } catch { }; try { // pagesource1 = GlobusHttpHelper.getHtmlfromUrlProxy(new Uri("http://web.stagram.com/"), proxyad, Convert.ToInt16(proxyport), proxyusername, proxyPassword); pagesource1 = objchilkat.GetHtmlProxy("http://web.stagram.com/", proxyad, proxyport, proxyusername, proxyPassword); } catch { }; //int FirstPointClientId = pagesource1.IndexOf("client_id="); //string FirstClientIdSubString = pagesource1.Substring(FirstPointClientId); //int SecondPointClientId = FirstClientIdSubString.IndexOf("&redirect_uri="); //string ClientId = FirstClientIdSubString.Substring(0, SecondPointClientId).Replace("'", string.Empty).Replace("client_id=", string.Empty).Trim(); //string LoginUrl = "https://instagram.com/accounts/login/?next=/oauth/authorize/%3Fclient_id%3D" + ClientId + "%26redirect_uri%3Dhttp%253A%252F%252Fweb.stagram.com%252F%26response_type%3Dcode%26scope%3Dlikes%2Bcomments%2Brelationships"; //pagesource = GlobusHttpHelper.getHtmlfromUrlProxy(new Uri(LoginUrl), proxyad, Convert.ToInt16(proxyport), proxyusername, proxyPassword); //if (string.IsNullOrEmpty(pagesource)) //{ // pagesource = string.Empty; // pagesource = GlobusHttpHelper.getHtmlfromUrlProxy(new Uri(LoginUrl), proxyad, Convert.ToInt16(proxyport), proxyusername, proxyPassword); //} //ADD in List list of Finally chacked..... if (!string.IsNullOrEmpty(pagesource1)) { if (proxyStop) return; addInFinalCheckedProxyist(proxyad, proxyport, proxyusername, proxyPassword, pagesource1); } else { if (proxyStop) return; DemoStagramPro.ClGlobul.isProxyCheckComplete = true; LoggerProxy("[ " + DateTime.Now + " ] => [ Proxy Is not Working : " + proxyad + ":" + proxyport + ":" + proxyusername + ":" + proxyPassword + " ]"); lock (lockerforNonWorkingProxies) { GramBoardProFileHelper.AppendStringToTextfileNewLine(proxyad + ":" + proxyport + ":" + proxyusername + ":" + proxyPassword, GramBoardProFileHelper.NonWorkingProxiesList); } } } catch (Exception) { if (proxyStop) return; LoggerProxy("[ " + DateTime.Now + " ] => [ Proxy Is not Working : " + proxyad + ":" + proxyport + ":" + proxyusername + ":" + proxyPassword + " ]"); lock (lockerforNonWorkingProxies) { GramBoardProFileHelper.AppendStringToTextfileNewLine(proxyad + ":" + proxyport + ":" + proxyusername + ":" + proxyPassword, GramBoardProFileHelper.NonWorkingProxiesList); } } finally { lock (lockerforProxies) { countParseProxiesThreads--; Monitor.Pulse(lockerforProxies); } Proxystatus--; if (Proxystatus == 0) { LoggerProxy("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]"); LoggerProxy("-----------------------------------------------------------------------------------------------------------------------------------"); } } }