public List <string> GetAllBoardNames_new(ref PinInterestUser objPinInUser) { List <string> BoardNames = new List <string>(); BaseLib.GlobusRegex rgx = new GlobusRegex(); Globussoft.GlobusHttpHelper httpHelper = new Globussoft.GlobusHttpHelper(); string UserUrl = "http://pinterest.com/" + objPinInUser.Username; string BoardPage = httpHelper.getHtmlfromUrl(new Uri(UserUrl), "", "", objPinInUser.UserAgent); string[] Items = Regex.Split(BoardPage, "item"); int counter = 0; foreach (string item in Items) { try { if (item.Contains("id=\\\"Board") && item.Contains("boardLinkWrapper")) { //if (counter == 1) { string[] Data = System.Text.RegularExpressions.Regex.Split(item, "boardLinkWrapper"); foreach (string Dataitem in Data) { if (Dataitem.Contains("-end-")) { continue; } if (Dataitem.Contains("boardName")) { int startIndex = Dataitem.IndexOf("title"); int LastPoint = Dataitem.IndexOf("<h4"); string Board = Dataitem.Substring(startIndex, LastPoint).Replace("\\n", string.Empty).Replace("\"", "").Replace("<div class=\\b", string.Empty).Replace(" ", string.Empty).Replace("\"title\"", "").Replace("</div", ""); Board = rgx.StripTagsRegex(Board); try { Board = Board.Split('>')[1]; } catch { } if (!BoardNames.Contains(Board)) { BoardNames.Add(Board); } } } } counter++; } } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } } return(BoardNames); }
private void ExtractDatas() { string aa = wbMain.DocumentText; GlobusRegex globusRegex = new GlobusRegex(); string name = globusRegex.GetH1Tag(aa); string Price = globusRegex.GetH3Tag(aa); }
private string GetValues(string Response, string RowNumber, string First, string End) { GlobusRegex g = new GlobusRegex(); ///Checking Values if (!string.IsNullOrEmpty(First) && !string.IsNullOrEmpty(End)) { //Replacing (") from Resonse string FormattedResponse = Response.Replace("\"", string.Empty); //Getting Start Set String string strStart = First.ToString().Replace("\"", string.Empty).Trim(); // Getting First Point from FormattedResponse int FirstPoint = FormattedResponse.IndexOf(strStart); if (FirstPoint > 0) { // Creating NewResponse Start from FirstPoint string NewResponse = FormattedResponse.Substring(FirstPoint); //Getting End Set String string strEnd = End.ToString().Replace("\"", string.Empty).Trim(); //Getting Second Point of NewResponse int SecondPoint = NewResponse.IndexOf(strEnd); if (SecondPoint > 0) { //Getting Result string Result = NewResponse.Substring(0, SecondPoint).Replace(strStart, string.Empty); //Stripping Html Tag For Final Result string FinalResult = g.StripTagsRegex(Result).Replace(",", string.Empty).Replace("\r\n", string.Empty).Replace("\n", string.Empty); return(FinalResult); } else { logger.LogStatus("RowNumber --" + RowNumber + "-- End Tag is not in well Format -- " + strEnd); return("ERR"); } } else { logger.LogStatus("RowNumber --" + RowNumber + "-- Start Tag is not in well Format -- " + strStart); return("ERR"); } } else { return("ERR"); } }
private void btnSaveDelaySetting_Click(object sender, EventArgs e) { if (GlobusRegex.ValidateNumber(txtGlobalMinDelay.Text)) { Globals.MinGlobalDelay = Convert.ToInt32(txtGlobalMinDelay.Text); Globals.IsCheckValueOfDelay = true; } else { Globals.IsCheckValueOfDelay = false; MessageBox.Show("Please Fill right Delay value."); return; } if (GlobusRegex.ValidateNumber(txtGlobalMaxDelay.Text)) { Globals.MaxGlobalDelay = Convert.ToInt32(txtGlobalMaxDelay.Text); Globals.IsCheckValueOfDelay = true; } else { Globals.IsCheckValueOfDelay = false; MessageBox.Show("Please Fill right Delay value."); return; } if (Globals.MinGlobalDelay > 0 && Globals.MaxGlobalDelay > 0 && Globals.IsCheckValueOfDelay) { //Event_DisableDelaySettings(""); MessageBox.Show("Delay value saved."); } else { //Event_EnableDelaySettings(""); MessageBox.Show("Please Fill right Delay value."); return; } }
private void StartUnFollowingMultithreaded(object parameters) { try { if (IsStopFollowYourFollowers) { return; } // if (!IsStopFollowYourFollowers) { lstIsStopFollowYourFollowers.Add(Thread.CurrentThread); lstIsStopFollowYourFollowers.Distinct(); Thread.CurrentThread.IsBackground = true; } Array paramsArray = new object[2]; paramsArray = (Array)parameters; int NoOfFollwos = 0; KeyValuePair <string, TweetAccountManager> keyValue = (KeyValuePair <string, TweetAccountManager>)paramsArray.GetValue(0); string NofUnfollows = (string)paramsArray.GetValue(1); if (!string.IsNullOrEmpty(NofUnfollows) && NumberHelper.ValidateNumber(NofUnfollows)) { NoOfFollwos = Int32.Parse(NofUnfollows); } bool OtherUser = false; frmMain_NewUI.IsFollowerScreenName = true; List <string> list_userIDsToFollow = new List <string>(); TweetAccountManager tweetAccountManager = keyValue.Value; AddToLog_follow("[ " + DateTime.Now + " ] => [following Process Started For Account : " + keyValue.Key + " ]"); //Add to Threads Dictionary //AddThreadToDictionary(strModule(Module.Follow), tweetAccountManager.Username); tweetAccountManager.unFollower.logEvents.addToLogger += new EventHandler(logEvents_Follower_addToLogger); tweetAccountManager.logEvents.addToLogger += logEvents_Follower_addToLogger; if (!tweetAccountManager.IsLoggedIn) { tweetAccountManager.Login(); } if (!tweetAccountManager.IsLoggedIn) { AddToLog_follow("[ " + DateTime.Now + " ] => [ Not Logged In With Account : " + keyValue.Key + " ]"); return; } //////////////temp mehtod { } //AddToLog_Unfollow("Checking for Persons Not Followed Back"); Thread thread_UnFollowing = null; //Check Test box and anf useing feature box is checked TwitterDataScrapper objTwitterDataScrapper = new TwitterDataScrapper(); //if (rdoFollowYourFollowers.Checked) //thread_UnFollowing = new Thread(() => //{ // list_userIDsToFollow = tweetAccountManager.GetFollowYourFollowersList(); //}); list_userIDsToFollow = tweetAccountManager.GetFollowYourFollowersList(); if (GlobusRegex.ValidateNumber(txtfollowMinDelay.Text)) { followMinDelay = Convert.ToInt32(txtfollowMinDelay.Text); } if (GlobusRegex.ValidateNumber(txtfollowMaxDelay.Text)) { followMaxDelay = Convert.ToInt32(txtfollowMaxDelay.Text); } if (list_userIDsToFollow.Count > 0) { tweetAccountManager.FollowUsingURLs(list_userIDsToFollow, followMinDelay, followMaxDelay, OtherUser); } else { AddToLog_follow("[ " + DateTime.Now + " ] => [ No user id is available for Account : " + keyValue.Key + " ]"); } tweetAccountManager.unFollower.logEvents.addToLogger -= logEvents_Follower_addToLogger; tweetAccountManager.logEvents.addToLogger -= logEvents_Follower_addToLogger; } catch (Exception ex) { ErrorLogger.AddToErrorLogText(ex.Message); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> StartUnFollowingMultithreaded() --> " + ex.Message, Globals.Path_UnfollowerErroLog); GlobusFileHelper.AppendStringToTextfileNewLine("Error --> StartUnFollowingMultithreaded() --> " + ex.Message, Globals.Path_TwtErrorLogs); } finally { counter_Account--; if (counter_Account == 0) { if (btnStartFollow.InvokeRequired) { btnStartFollow.Invoke(new MethodInvoker(delegate { AddToLog_follow("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]"); AddToLog_follow("---------------------------------------------------------------------------------------------------------------------------"); btnStartFollow.Cursor = Cursors.Default; })); } } } }
public List <string> GetAllBoardNames_new1(string screenName, ref PinInterestUser objPinUser) { try { BaseLib.GlobusRegex rgx = new GlobusRegex(); GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Getting All Board Names ]"); Globussoft.GlobusHttpHelper httpHelper = new Globussoft.GlobusHttpHelper(); string UserUrl = "http://pinterest.com/" + screenName; string BoardPage = httpHelper.getHtmlfromUrl(new Uri(UserUrl), "", "", ""); string[] data = Regex.Split(BoardPage, "is_collaborative"); foreach (var itemdata in data) { string boardUrl = Utils.Utils.getBetween(itemdata, ", \"url\":", ",").Replace("\"", "").Trim(); if (!ClGlobul.lstBoardUrls.Contains(boardUrl) && !string.IsNullOrEmpty(boardUrl)) { ClGlobul.lstBoardUrls.Add(boardUrl); } if (itemdata.Contains("board_id")) { string boardId = Utils.Utils.getBetween(itemdata, "board_id\":", ",").Replace("\"", "").Trim(); if (!ClGlobul.lstBoardId.Contains(boardId)) { ClGlobul.lstBoardId.Add(boardId); } } } string[] Items = Regex.Split(BoardPage, "item"); int counter = 0; foreach (string item in Items) { try { if (item.Contains("id=\\\"Board") && item.Contains("boardLinkWrapper")) { string[] Data = System.Text.RegularExpressions.Regex.Split(item, "boardLinkWrapper"); foreach (string Dataitem in Data) { if (Dataitem.Contains("boardName")) { string BoardUrl = string.Empty; int startIndex = Dataitem.IndexOf("title"); int LastPoint = Dataitem.IndexOf("<h2"); string Board = Dataitem.Substring(startIndex, LastPoint).Replace("\\n", string.Empty).Replace("\"", "").Replace("<div class=\\b", string.Empty).Replace(" ", string.Empty).Replace("\"title\"", "").Replace("</div", ""); BoardUrl = rgx.StripTagsRegex(Board); try { Board = Utils.Utils.getBetween(BoardUrl, ">>", "<"); //modified done if (Board == "") { Board = Utils.Utils.getBetween(BoardUrl, "title=", ">").Replace("\\", "").Trim(); } } catch { } if (!ClGlobul.BoardNames.Contains(Board)) { ClGlobul.BoardNames.Add(Board); } } } counter++; } } catch (Exception ex) { } } } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } return(ClGlobul.BoardNames); }
public int GetPageNo(string PageSource) { int pageNo = 0; try { string strpageNo = GlobusRegex.ParseJson(PageSource, "resultCount"); strpageNo = GlobusRegex.ParseEncodedJson(PageSource, "resultCount"); if (!string.IsNullOrEmpty(strpageNo)) { pageNo = int.Parse(strpageNo); } } catch { } if (pageNo != 0) { return(pageNo); } try { string ResponseForScrapper = string.Empty; //int pagenumber = 0; ResponseForScrapper = PageSource; string strPageNumber = string.Empty; string[] Arr12 = Regex.Split(ResponseForScrapper, "<p class=\"summary\">"); foreach (string item in Arr12) { try { if (!item.Contains("<!DOCTYPE")) { if (item.Contains("<strong>")) { try { string pageNO = item.Substring(item.IndexOf("<strong>"), item.IndexOf("</strong>", item.IndexOf("<strong>")) - item.IndexOf("<strong>")).Replace("<strong>", string.Empty).Replace(",", string.Empty).Trim(); string[] arrPageNO = Regex.Split(pageNO, "[^0-9]"); foreach (string item1 in arrPageNO) { try { if (!string.IsNullOrEmpty(item1)) { strPageNumber = item1; pageNo = Convert.ToInt32(strPageNumber); } } catch { } } } catch { } } else { try { string pageNO = item.Substring(item.IndexOf("<p class=\"summary\">"), item.IndexOf("</p>", item.IndexOf("<p class=\"summary\">")) - item.IndexOf("<p class=\"summary\">")).Replace("<p class=\"summary\">", string.Empty).Replace(",", string.Empty).Trim(); string[] arrPageNO = Regex.Split(pageNO, "[^0-9]"); foreach (string item1 in arrPageNO) { try { if (!string.IsNullOrEmpty(item1)) { strPageNumber = item1; } } catch { } } } catch { } } } } catch { } } } catch { } return(pageNo); }
private void btnStart_Searching_Click(object sender, EventArgs e) { AllOfTheseWords = (txtAllofTheseKeywords.Text).ToString(); ThisExtractPhrase = (txtThisExactPhrase.Text).ToString(); AnyOfTheseWords = (txtAnyOfTheseWords.Text).ToString(); TheseHashTags = (txtTheseHashTags.Text).ToString(); NoneOfTheseWords = (txtNoneofTheseWords.Text).ToString(); FromTheseAccounts = (txtFromTheseAccounts.Text).ToString(); ToTheseAccounts = (txtToTheseAccounts.Text).ToString(); MentionTheseAccounts = (txtMentioningTheseAccounts.Text).ToString(); NearThisPlace = (txtNearThisPlace.Text).ToString(); AddToLog_AdvancedSearch("[ " + DateTime.Now + " ] => Process Started"); try { if (string.IsNullOrEmpty(ThisExtractPhrase)) { ThisExtractPhrase = ""; } else { ThisExtractPhrase = "%20%22" + ThisExtractPhrase; } } catch { } try { if (string.IsNullOrEmpty(AnyOfTheseWords)) { AnyOfTheseWords = ""; } else { AnyOfTheseWords = "%22%20" + AnyOfTheseWords; } } catch { } try { if (string.IsNullOrEmpty(TheseHashTags)) { TheseHashTags = ""; } else { TheseHashTags = "%20%23" + TheseHashTags; } } catch { } try { if (string.IsNullOrEmpty(NoneOfTheseWords)) { NoneOfTheseWords = ""; } else { NoneOfTheseWords = "%20-" + NoneOfTheseWords; } } catch { } try { if (string.IsNullOrEmpty(FromTheseAccounts)) { FromTheseAccounts = ""; } else { FromTheseAccounts = "%20from%3A" + FromTheseAccounts; } } catch { } try { if (string.IsNullOrEmpty(ToTheseAccounts)) { ToTheseAccounts = ""; } else { ToTheseAccounts = "%20to%3A" + ToTheseAccounts; } } catch { } try { if (string.IsNullOrEmpty(MentionTheseAccounts)) { MentionTheseAccounts = ""; } else { MentionTheseAccounts = "%20%40" + MentionTheseAccounts; } } catch { } try { if (string.IsNullOrEmpty(NearThisPlace)) { NearThisPlace = ""; } else { NearThisPlace = "%20near%3A%22" + NearThisPlace; } } catch { } try { if (!string.IsNullOrEmpty(txtAllofTheseKeywords.Text)) { #region Commented //try //{ // string Url = "https://twitter.com/search?f=realtime&q=" + AllOfTheseWords + ThisExtractPhrase + AnyOfTheseWords + NoneOfTheseWords + TheseHashTags + _selectedLanguage + FromTheseAccounts + ToTheseAccounts + MentionTheseAccounts + NearThisPlace + "%22%20within%3A15mi&src=typd"; // string response = _GlobusHttpHelper.getHtmlfromUrl(new Uri(Url), "", ""); //} //catch { } public List<StructTweetIDs> NewKeywordStructDataForSearchByKeyword(string keyword) #endregion { try { BaseLib.GlobusRegex regx = new GlobusRegex(); int counter = 0; string res_Get_searchURL = string.Empty; string searchURL = string.Empty; string maxid = string.Empty; string TweetId = string.Empty; string text = string.Empty; string ProfileName = string.Empty; string Location = string.Empty; string Bio = string.Empty; string website = string.Empty; string NoOfTweets = string.Empty; string Followers = string.Empty; string Followings = string.Empty; int noOfRecords = 0; try { noOfRecords = int.Parse(txtNoOfRecords.Text); } catch { } startAgain: if (counter == 0) { searchURL = "https://twitter.com/i/search/timeline?q=" + AllOfTheseWords + ThisExtractPhrase + AnyOfTheseWords + NoneOfTheseWords + TheseHashTags + _selectedLanguage + FromTheseAccounts + ToTheseAccounts + MentionTheseAccounts + NearThisPlace + "%22%20within%3A15mi&src=typd" + "&f=realtime"; counter++; } else { searchURL = "https://twitter.com/i/search/timeline?q=" + AllOfTheseWords + ThisExtractPhrase + AnyOfTheseWords + NoneOfTheseWords + TheseHashTags + _selectedLanguage + FromTheseAccounts + ToTheseAccounts + MentionTheseAccounts + NearThisPlace + "%22%20within%3A15mi&src=typd" + "&f=realtime&include_available_features=1&include_entities=1&last_note_ts=0&oldest_unread_id=0&scroll_cursor=" + TweetId + ""; } try { res_Get_searchURL = _GlobusHttpHelper.getHtmlfromUrl(new Uri(searchURL), "", ""); AddToLog_AdvancedSearch("[ " + DateTime.Now + " ] => Finding results for entered details "); if (string.IsNullOrEmpty(res_Get_searchURL)) { res_Get_searchURL = _GlobusHttpHelper.getHtmlfromUrl(new Uri(searchURL), "", ""); } try { //string sjss = globushttpHelper.getHtmlfromUrl(new Uri(searchURL), "", ""); string[] splitRes = Regex.Split(res_Get_searchURL, "refresh_cursor"); //splitRes = splitRes.Skip(1).ToArray(); foreach (string item in splitRes) { if (item.Contains("refresh_cursor")) { int startIndex = item.IndexOf("TWEET-"); string start = item.Substring(startIndex).Replace("data-user-id=\\\"", ""); int endIndex = start.IndexOf("\""); string end = start.Substring(0, endIndex).Replace("id_str", "").Replace("\"", "").Replace(":", "").Replace("{", "").Replace("}", "").Replace("]", ""); TweetId = end; } if (item.Contains("scroll_cursor")) { int startIndex = item.IndexOf("TWEET-"); string start = item.Substring(startIndex).Replace("data-user-id=\\\"", ""); int endIndex = start.IndexOf("\""); string end = start.Substring(0, endIndex).Replace("id_str", "").Replace("\"", "").Replace(":", "").Replace("{", "").Replace("}", "").Replace("]", ""); TweetId = end; } } } catch (Exception) { } } catch (Exception ex) { System.Threading.Thread.Sleep(2000); res_Get_searchURL = _GlobusHttpHelper.getHtmlfromUrl(new Uri(searchURL), "", ""); } // && !res_Get_searchURL.Contains("has_more_items\":false") if (!string.IsNullOrEmpty(res_Get_searchURL)) { //string[] splitRes = Regex.Split(res_Get_searchURL, "data-item-id"); //Regex.Split(res_Get_searchURL, "\"in_reply_to_status_id_str\""); string[] splitRes = Regex.Split(res_Get_searchURL, "data-item-id"); splitRes = splitRes.Skip(1).ToArray(); foreach (string item in splitRes) { if (item.Contains("data-screen-name=") && !item.Contains("js-actionable-user js-profile-popup-actionable")) { //var avc = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(res_Get_searchURL); //string DataHtml = (string)avc["items_html"]; } else { continue; } string modified_Item = "\"from_user\"" + item; string id = ""; try { int startIndex = item.IndexOf("data-user-id="); string start = item.Substring(startIndex).Replace("data-user-id=\\\"", ""); int endIndex = start.IndexOf("\\\""); string end = start.Substring(0, endIndex).Replace("id_str", "").Replace("\"", "").Replace(":", "").Replace("{", "").Replace("}", "").Replace("]", ""); id = end; //lst_structTweetIDs.Add(id); AddToLog_AdvancedSearch("[ " + DateTime.Now + " ] => User Id " + id); } catch (Exception ex) { id = "null"; //Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetPhotoFromUsername() -- id -- " + keyword + " --> " + ex.Message, Globals.Path_TwitterDataScrapper); } string from_user_id = ""; try { int startIndex = item.IndexOf("data-screen-name=\\\""); string start = item.Substring(startIndex).Replace("data-screen-name=\\\"", ""); int endIndex = start.IndexOf("\\\""); string end = start.Substring(0, endIndex).Replace("from_user_id\":", "").Replace("\"", "").Replace(":", "").Replace("{", "").Replace("_str", "").Replace("user", "").Replace("}", "").Replace("]", ""); from_user_id = end; AddToLog_AdvancedSearch("[ " + DateTime.Now + " ] => User ScreenName " + from_user_id); } catch (Exception ex) { from_user_id = "null"; // Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetPhotoFromUsername() -- " + keyword + " -- from_user_id --> " + ex.Message, Globals.Path_TwitterDataScrapper); } string tweetUserid = string.Empty; try { int startIndex = item.IndexOf("=\\\""); string start = item.Substring(startIndex).Replace("=\\\"", ""); int endIndex = start.IndexOf("\\\""); string end = start.Substring(0, endIndex).Replace("from_user_id\":", "").Replace("\"", "").Replace(":", "").Replace("{", "").Replace("_str", "").Replace("user", "").Replace("}", "").Replace("]", ""); tweetUserid = end; AddToLog_AdvancedSearch("[ " + DateTime.Now + " ] => Tweet Id " + tweetUserid); } catch (Exception ex) { from_user_id = "null"; } ///Tweet Text #region Commented //try //{ // int startindex = item.IndexOf("js-tweet-text tweet-text\""); // if (startindex == -1) // { // startindex = 0; // startindex = item.IndexOf("js-tweet-text tweet-text"); // } // string start = item.Substring(startindex).Replace("js-tweet-text tweet-text\"", "").Replace("js-tweet-text tweet-text tweet-text-rtl\"", ""); // int endindex = start.IndexOf("</p>"); // if (endindex == -1) // { // endindex = 0; // endindex = start.IndexOf("stream-item-footer"); // } // string end = start.Substring(0, endindex); // end = regx.StripTagsRegex(end); // text = end.Replace(" ", "").Replace("a href=", "").Replace("/a", "").Replace("<span", "").Replace("</span", "").Replace("class=\\\"js-display-url\\\"", "").Replace("class=\\\"tco-ellipsis\\\"", "").Replace("class=\\\"invisible\\\"", "").Replace("<strong>", "").Replace("target=\\\"_blank\\\"", "").Replace("class=\\\"twitter-timeline-link\\\"", "").Replace("</strong>", "").Replace("rel=\\\"nofollow\\\" dir=\\\"ltr\\\" data-expanded-url=", ""); // text = text.Replace(""", "").Replace("<", "").Replace(">", "").Replace("\"", "").Replace("\\", "").Replace("title=", ""); // string[] array = Regex.Split(text, "http"); // text = string.Empty; // foreach (string itemData in array) // { // if (!itemData.Contains("t.co")) // { // string data = string.Empty; // if (itemData.Contains("//")) // { // data = ("http" + itemData).Replace(" span ", string.Empty); // if (!text.Contains(itemData.Replace(" ", "")))// && !data.Contains("class") && !text.Contains(data)) // { // text += data.Replace("u003c", string.Empty).Replace("u003e", string.Empty); // } // } // else // { // if (!text.Contains(itemData.Replace(" ", ""))) // { // text += itemData.Replace("u003c", string.Empty).Replace("u003e", string.Empty).Replace("js-tweet-text tweet-text", ""); // } // } // } // } //} //catch { }; #endregion twtboardpro.TwitterDataScrapper.StructTweetIDs structTweetIDs = new twtboardpro.TwitterDataScrapper.StructTweetIDs(); if (id != "null") { structTweetIDs.ID_Tweet = tweetUserid; structTweetIDs.ID_Tweet_User = id; structTweetIDs.username__Tweet_User = from_user_id; structTweetIDs.wholeTweetMessage = text; lst_structTweetIDs.Add(structTweetIDs); } //if (!File.Exists(Globals.Path_KeywordScrapedListData + "-" + keyword + ".csv")) //{ // GlobusFileHelper.AppendStringToTextfileNewLine("USERID , USERNAME , PROFILE NAME , BIO , LOCATION , WEBSITE , NO OF TWEETS , FOLLOWERS , FOLLOWINGS", Globals.Path_KeywordScrapedListData + "-" + keyword + ".csv"); //} { ChilkatHttpHelpr objChilkat = new ChilkatHttpHelpr(); GlobusHttpHelper HttpHelper = new GlobusHttpHelper(); string ProfilePageSource = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + from_user_id), "", ""); string Responce = ProfilePageSource; #region Convert HTML to XML string xHtml = objChilkat.ConvertHtmlToXml(Responce); Chilkat.Xml xml = new Chilkat.Xml(); xml.LoadXml(xHtml); Chilkat.Xml xNode = default(Chilkat.Xml); Chilkat.Xml xBeginSearchAfter = default(Chilkat.Xml); #endregion int counterdata = 0; xBeginSearchAfter = null; string dataDescription = string.Empty; xNode = xml.SearchForAttribute(xBeginSearchAfter, "h1", "class", "ProfileHeaderCard-name"); while ((xNode != null)) { xBeginSearchAfter = xNode; if (counterdata == 0) { ProfileName = xNode.AccumulateTagContent("text", "script|style"); counterdata++; } else if (counterdata == 1) { website = xNode.AccumulateTagContent("text", "script|style"); counterdata++; } else { break; } xNode = xml.SearchForAttribute(xBeginSearchAfter, "a", "class", "u-textUserColor"); } xBeginSearchAfter = null; dataDescription = string.Empty; xNode = xml.SearchForAttribute(xBeginSearchAfter, "p", "class", "ProfileHeaderCard-bio u-dir");//bio profile-field"); while ((xNode != null)) { xBeginSearchAfter = xNode; Bio = xNode.AccumulateTagContent("text", "script|style").Replace("'", "'").Replace(" ", string.Empty).Trim(); break; } xBeginSearchAfter = null; dataDescription = string.Empty; xNode = xml.SearchForAttribute(xBeginSearchAfter, "span", "class", "ProfileHeaderCard-locationText u-dir");//location profile-field"); while ((xNode != null)) { xBeginSearchAfter = xNode; Location = xNode.AccumulateTagContent("text", "script|style"); break; } int counterData = 0; xBeginSearchAfter = null; dataDescription = string.Empty; xNode = xml.SearchForAttribute(xBeginSearchAfter, "a", "class", "ProfileNav-stat ProfileNav-stat--link u-borderUserColor u-textCenter js-tooltip js-nav");//location profile-field"); while ((xNode != null)) { xBeginSearchAfter = xNode; if (counterData == 0) { // NoOfTweets = xml.SearchForAttribute(xBeginSearchAfter, "span", "class", "ProfileNav-value"); NoOfTweets = xNode.AccumulateTagContent("text", "script|style").Replace("Tweets", string.Empty).Replace(",", string.Empty).Replace("Tweet", string.Empty); counterData++; } else if (counterData == 1) { Followings = xNode.AccumulateTagContent("text", "script|style").Replace(" Following", string.Empty).Replace(",", string.Empty).Replace("Following", string.Empty); counterData++; } else if (counterData == 2) { Followers = xNode.AccumulateTagContent("text", "script|style").Replace("Followers", string.Empty).Replace(",", string.Empty).Replace("Follower", string.Empty); counterData++; } else { break; } //xNode = xml.SearchForAttribute(xBeginSearchAfter, "a", "class", "js-nav"); xNode = xml.SearchForAttribute(xBeginSearchAfter, "a", "class", "ProfileNav-stat ProfileNav-stat--link u-borderUserColor u-textCenter js-tooltip js-openSignupDialog js-nonNavigable u-textUserColor"); } if (!string.IsNullOrEmpty(from_user_id) && tweetUserid != "null") { string Id_user = tweetUserid.Replace("}]", string.Empty).Trim(); Globals.lstScrapedUserIDs.Add(Id_user); // GlobusFileHelper.AppendStringToTextfileNewLine(id + "," + from_user_id + "," + ProfileName + "," + Bio.Replace(",", "") + "," + Location.Replace(",", "") + "," + website + "," + NoOfTweets.Replace(",", "").Replace("Tweets", "") + "," + Followers.Replace(",", "").Replace("Following", "") + "," + Followings.Replace(",", "").Replace("Followers", "").Replace("Follower", ""), Globals.Path_KeywordScrapedListData + "-" + keyword + ".csv"); // Log("[ " + DateTime.Now + " ] => [ " + from_user_id + "," + Id_user + "," + ProfileName + "," + Bio.Replace(",", "") + "," + Location + "," + website + "," + NoOfTweets + "," + Followers + "," + Followings + " ]"); } } lst_structTweetIDs = lst_structTweetIDs.Distinct().ToList(); if (lst_structTweetIDs.Count >= noOfRecords) { // return lst_structTweetIDs; } } if (lst_structTweetIDs.Count <= noOfRecords) { maxid = lst_structTweetIDs[lst_structTweetIDs.Count - 1].ID_Tweet; if (res_Get_searchURL.Contains("has_moreitems\":false")) { } else { goto startAgain; } } else { if (res_Get_searchURL.Contains("has_more_items\":false")) { } else { goto startAgain; } } } } catch (Exception ex) { } } } } catch { } }
public Form1() { httpHelper = new GlobusHttpHelper(); globusRegex = new GlobusRegex(); InitializeComponent(); }
private void AssignProxy() { try { if (MessageBox.Show("Assign Private/Public proxies from Database???", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { List <string> lstProxies = proxyFetcher.GetPublicProxies(); if (lstProxies.Count > 0) { if (!string.IsNullOrEmpty(txtAccountsPerProxy.Text) && GlobusRegex.ValidateNumber(txtAccountsPerProxy.Text)) { try { accountsPerProxy = int.Parse(txtAccountsPerProxy.Text); } catch { accountsPerProxy = 10; } } AddLoggerAccountLoad("[ " + DateTime.Now + " ] => [ Please Wait Process Running ....! ]"); proxyFetcher.AssignProxiesToAccounts(lstProxies, accountsPerProxy); //AssignProxiesToAccounts(lstProxies); LoadDataGrid(); //Refresh Datagrid if (dgvAccount.RowCount > 1) { AddLoggerAccountLoad("[ " + DateTime.Now + " ] => [ All Proxy has been Alloted. ]"); } else { AddLoggerAccountLoad("[ " + DateTime.Now + " ] => [ Please Load Some Account ]"); } } else { MessageBox.Show("Please assign Private/Public proxies from Proxies Tab in Main Page OR Upload a proxies Text File"); } } catch { } } else { try { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.Filter = "Text Files (*.txt)|*.txt"; ofd.InitialDirectory = Application.StartupPath; if (ofd.ShowDialog() == DialogResult.OK) { lstProxies = new List <string>(); lstProxies = GlobusFileHelper.ReadFiletoStringList(ofd.FileName); if (!string.IsNullOrEmpty(txtAccountsPerProxy.Text) && GlobusRegex.ValidateNumber(txtAccountsPerProxy.Text)) { try { accountsPerProxy = int.Parse(txtAccountsPerProxy.Text); } catch { accountsPerProxy = 10; } } AddLoggerAccountLoad("[ " + DateTime.Now + " ] => [ Please Wait Process Running ....! ]"); proxyFetcher.AssignProxiesToAccounts(lstProxies, accountsPerProxy); //AssignProxiesToAccounts(lstProxies); LoadDataGrid(); //Refresh Datagrid //AssignProxiesToAccountsModified(); } } } catch { } } AddLoggerAccountLoad("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]"); AddLoggerAccountLoad("----------------------------------------------------------------------------------------"); } catch { } }
private void StartMessagingMultithreaded(object parameters) { try { if (IsStopDirectMessages) { return; } if (!IsStopDirectMessages) { lstIsStopMessaging.Add(Thread.CurrentThread); lstIsStopMessaging.Distinct(); Thread.CurrentThread.IsBackground = true; } List <string> list_userIDsToFollow = new List <string>(); Array paramsArray = new object[2]; paramsArray = (Array)parameters; int NoOfFollwos = 0; KeyValuePair <string, TweetAccountManager> keyValue = (KeyValuePair <string, TweetAccountManager>)paramsArray.GetValue(0); string NofUnfollows = (string)paramsArray.GetValue(1); if (!string.IsNullOrEmpty(NofUnfollows) && NumberHelper.ValidateNumber(NofUnfollows)) { NoOfFollwos = Int32.Parse(NofUnfollows); } bool OtherUser = false; //frmMain_NewUI.IsFollowerScreenName = true; GlobusHttpHelper objGlobusHttpHelper = new GlobusHttpHelper(); TweetAccountManager tweetAccountManager = keyValue.Value; tweetAccountManager.unFollower.logEvents.addToLogger += new EventHandler(logEvents_Follower_addToLogger); tweetAccountManager.logEvents.addToLogger += logEvents_Follower_addToLogger; if (!tweetAccountManager.IsLoggedIn) { tweetAccountManager.Login(); } if (!tweetAccountManager.IsLoggedIn) { AddToLog_follow("[ " + DateTime.Now + " ] => [ Not Logged In With Account : " + keyValue.Key + " ]"); return; } if (GlobusRegex.ValidateNumber(txtDirectMessageMinDelay.Text)) { followMinDelay = Convert.ToInt32(txtDirectMessageMinDelay.Text); } if (GlobusRegex.ValidateNumber(txtDirectMessageMaxDelay.Text)) { followMaxDelay = Convert.ToInt32(txtDirectMessageMaxDelay.Text); } //TwitterDataScrapper objTwitterDataScrapper = new TwitterDataScrapper(); if (list_userIDsToFollowForDirectMessage.Count > 0 && chkFollowers.Checked) { list_userIDsToFollow.AddRange(list_userIDsToFollowForDirectMessage); } else { list_userIDsToFollow = tweetAccountManager.GetFollowerListForDirectMessage(); } if (list_userIDsToFollow.Count > 0) { tweetAccountManager.PostDirectMessage(list_userIDsToFollow, followMinDelay, followMaxDelay, OtherUser); } else { AddToLog_follow("[ " + DateTime.Now + " ] => [ No user id is available for Account : " + keyValue.Key + " ]"); } tweetAccountManager.unFollower.logEvents.addToLogger -= logEvents_Follower_addToLogger; tweetAccountManager.logEvents.addToLogger -= logEvents_Follower_addToLogger; } catch (Exception ex) { ErrorLogger.AddToErrorLogText(ex.Message); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> StartUnFollowingMultithreaded() --> " + ex.Message, Globals.Path_UnfollowerErroLog); GlobusFileHelper.AppendStringToTextfileNewLine("Error --> StartUnFollowingMultithreaded() --> " + ex.Message, Globals.Path_TwtErrorLogs); } finally { counter_Account--; if (counter_Account == 0) { if (btnStartMessaging.InvokeRequired) { btnStartMessaging.Invoke(new MethodInvoker(delegate { AddToLog_follow("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]"); AddToLog_follow("---------------------------------------------------------------------------------------------------------------------------"); btnStartMessaging.Cursor = Cursors.Default; })); } } } }
public static bool GetStatusLinks(string username) { int counter = 0; Globussoft.GlobusHttpHelper httpHelper = new Globussoft.GlobusHttpHelper(); string user_id = string.Empty; bool tooManyLinks = true; try { string text = string.Empty; string PageSource = string.Empty; //http://a0.twimg.com/sticky/default_profile_images/default_profile_0_normal.png if (!string.IsNullOrEmpty(username) && NumberHelper.ValidateNumber(username)) { PageSource = httpHelper.getHtmlfromUrl(new Uri("https://api.twitter.com/1/statuses/user_timeline.xml?include_entities=true&inc%E2%80%8C%E2%80%8Blude_rts=true&include_rts=1&user_id=" + username + "&count=" + noOfstatus), "", ""); } else { PageSource = httpHelper.getHtmlfromUrl(new Uri("https://api.twitter.com/1/statuses/user_timeline.xml?include_entities=true&inc%E2%80%8C%E2%80%8Blude_rts=true&include_rts=1&screen_name=" + username + "&count=" + noOfstatus), "", ""); } if (!string.IsNullOrEmpty(PageSource) && PageSource.Contains("Sorry, that page does not exist")) { return(tooManyLinks); } if (!string.IsNullOrEmpty(PageSource)) { string[] statusArray = Regex.Split(PageSource, "<status>"); statusArray = statusArray.Skip(1).ToArray(); foreach (string Status in statusArray) { try { int indexStart = Status.IndexOf("<text>"); if (Status.Contains("<profile_image_url>")) { string start = Status.Substring(indexStart); int endIndex = start.IndexOf("</text>"); string end = start.Substring(0, endIndex); text = end.Replace("<text>", ""); } List <string> GetHrefs = GlobusRegex.GetHrefsFromString(text); if (GetHrefs.Count >= 1) { counter++; } } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetStatusLinks() -- " + username + " --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetStatusLinks() -- " + username + " --> " + ex.Message, Globals.Path_TwtErrorLogs); } } //FollowingsFollowersRatio_user_id = (count_Followings_user_id * 100) / count_Followers_user_id; int PerLinks = (counter * 100) / 20; //double PerLinks = a * 100; if (PerLinks > Percentage) { tooManyLinks = false; } } else { tooManyLinks = false; } } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetStatusLinks() -- " + username + " --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetStatusLinks() -- " + username + " --> " + ex.Message, Globals.Path_TwtErrorLogs); } return(tooManyLinks); }