Ejemplo n.º 1
0
        private List<string> GetTweetTime(Globussoft.GlobusHttpHelper globusHttpHelper, string pageSource)
        {
            List<string> lstTweetTime = new List<string>();
            try
            {
                if (pageSource.Contains("permalink-inner permalink-tweet-container"))
                {
                    // string[] arrTweetUsername = Regex.Split(pageSource, "permalink-inner permalink-tweet-container");
                    string TweetUserName = globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pageSource, "div", "permalink-inner permalink-tweet-container");

                    if (TweetUserName.Contains("client-and-actions") || TweetUserName.Contains("_timestamp js-short-timestamp "))
                    {
                        if (TweetUserName.Contains("_timestamp js-short-timestamp "))
                        {
                            List<string> lstTime = globusHttpHelper.GetTextDataByTagAndAttributeName(TweetUserName, "span", "_timestamp js-short-timestamp ");

                            foreach (string item in lstTime)
                            {
                                try
                                {
                                    if (item.Contains("-"))
                                    {
                                        string[] arrItem = Regex.Split(item, "-");
                                        if (arrItem.Count() > 1)
                                        {
                                            lstTweetTime.Add(arrItem[1].Trim());
                                        }
                                    }
                                    else
                                    {
                                        lstTweetTime.Add(item.Trim());
                                    }
                                }
                                catch
                                {
                                }
                            }

                        }

                        //if (lstTweetTime.Count < 1)
                        {
                            if (TweetUserName.Contains("client-and-actions"))
                            {
                                List<string> lstTime = globusHttpHelper.GetTextDataByTagAndAttributeName(TweetUserName, "div", "client-and-actions");

                                foreach (string item in lstTime)
                                {
                                    try
                                    {
                                        if (item.Contains("-"))
                                        {
                                            string[] arrItem = Regex.Split(item, "-");
                                            if (arrItem.Count() > 1)
                                            {
                                                lstTweetTime.Add(arrItem[1].Trim());
                                            }
                                        }
                                        else
                                        {
                                            lstTweetTime.Add(item.Trim());
                                        }

                                    }
                                    catch
                                    {
                                    }
                                }

                            }
                        }
                    }
                }
            }
            catch
            {
            }
            return lstTweetTime;
        }
Ejemplo n.º 2
0
        private List<string> GetReplyTime(Globussoft.GlobusHttpHelper globusHttpHelper, string pageSource)
        {
            List<string> lstReplyTime = new List<string>();

            try
            {
                if (pageSource.Contains("tweets-wrapper"))
                {
                    try
                    {
                        string ReplyUserName = globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pageSource, "div", "tweets-wrapper");

                        if (ReplyUserName.Contains("client-and-actions") || ReplyUserName.Contains("_timestamp js-short-timestamp "))
                        {
                            if (ReplyUserName.Contains("_timestamp js-short-timestamp "))
                            {
                                List<string> lstTime = globusHttpHelper.GetTextDataByTagAndAttributeName(ReplyUserName, "span", "_timestamp js-short-timestamp ");

                                foreach (string item in lstTime)
                                {
                                    try
                                    {
                                        if (item.Contains("-"))
                                        {
                                            string[] arrItem = Regex.Split(item, "-");
                                            if (arrItem.Count() > 1)
                                            {
                                                lstReplyTime.Add(arrItem[1].Trim());
                                            }
                                        }
                                        else
                                        {
                                            lstReplyTime.Add(item.Trim());
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }

                            }

                            if (ReplyUserName.Contains("client-and-actions"))
                            {
                                List<string> lstTime = globusHttpHelper.GetTextDataByTagAndAttributeName(ReplyUserName, "div", "client-and-actions");

                                foreach (string item in lstTime)
                                {
                                    try
                                    {
                                        if (item.Contains("-"))
                                        {
                                            string[] arrItem = Regex.Split(item, "-");
                                            if (arrItem.Count() > 1)
                                            {
                                                lstReplyTime.Add(arrItem[1].Trim());
                                            }
                                        }
                                        else
                                        {
                                            lstReplyTime.Add(item.Trim());
                                        }

                                    }
                                    catch
                                    {
                                    }
                                }

                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch
            {
            }

            return lstReplyTime;
        }
Ejemplo n.º 3
0
        private List<string> GetReplyUserId(Globussoft.GlobusHttpHelper globusHttpHelper, string pageSource)
        {
            List<string> lstReplyUserId = new List<string>();
            try
            {

                //string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri(url), "", "");

                if (pageSource.Contains("tweets-wrapper"))
                {
                    try
                    {
                        string ReplyUserId = globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pageSource, "div", "tweets-wrapper");
                        if (ReplyUserId.Contains("data-user-id="))
                        {
                            try
                            {
                                string[] arrDataUserId = Regex.Split(ReplyUserId, "data-user-id=");
                                foreach (string item in arrDataUserId)
                                {
                                    try
                                    {
                                        if (!item.Contains("<div class=\"tweets-wrapper\">") && item.Contains(" "))
                                        {
                                            string ReplyUserId1 = item.Substring(0, item.IndexOf(" ")).Replace("\"", string.Empty).Replace(">", string.Empty).Trim();
                                            string[] arrReplyUserId1 = Regex.Split(ReplyUserId1, "[a-zA-Z]");
                                            lstReplyUserId.Add(arrReplyUserId1[0]);
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    catch
                    {
                    }
                }

            }
            catch
            {
            }
            //lstReplyUserId=lstReplyUserId.Distinct().ToList();
            return lstReplyUserId;
        }
Ejemplo n.º 4
0
        private List<string> GetReplyUserName(Globussoft.GlobusHttpHelper globusHttpHelper, string pageSource)
        {
            List<string> lstReplyUserName = new List<string>();
            try
            {

                //string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri(url), "", "");

                if (pageSource.Contains("tweets-wrapper"))
                {
                    try
                    {
                        string ReplyUserName = globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pageSource, "div", "tweets-wrapper");
                        if (ReplyUserName.Contains("username js-action-profile-name"))
                        {
                            try
                            {
                                List<string> lst_ReplyUserName = globusHttpHelper.GetTextDataByTagAndAttributeName(ReplyUserName, "span", "username js-action-profile-name");

                                foreach (string item in lst_ReplyUserName)
                                {
                                    try
                                    {
                                        if (!string.IsNullOrEmpty(item) && !string.IsNullOrWhiteSpace(item))
                                        {
                                            lstReplyUserName.Add(item);
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    catch
                    {
                    }
                }

            }
            catch
            {
            }
            lstReplyUserName = lstReplyUserName.Distinct().ToList();
            return lstReplyUserName;
        }
Ejemplo n.º 5
0
        private List<string> GetReply(Globussoft.GlobusHttpHelper globusHttpHelper, string pageSource)
        {
            List<string> lstReply = new List<string>();
            try
            {
                //string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri(url), "", "");

                if (pageSource.Contains("tweets-wrapper"))
                {
                    try
                    {
                        string TweetUserId = globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pageSource, "div", "tweets-wrapper");
                        if (TweetUserId.Contains("js-tweet-text"))
                        {
                            List<string> lstTweetReply = globusHttpHelper.GetTextDataByTagAndAttributeName(TweetUserId, "p", "js-tweet-text");
                            foreach (string item in lstTweetReply)
                            {
                                lstReply.Add(item.Replace("&amp;", string.Empty).Replace("quot;", string.Empty));
                            }
                            //lstReply.AddRange(lstTweetReply);
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch
            {
            }
            return lstReply;
        }
Ejemplo n.º 6
0
        private List<string> GetTweetUserId(Globussoft.GlobusHttpHelper globusHttpHelper, string pageSource)
        {
            List<string> lstTweetId = new List<string>();
            try
            {
                //string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri(url), "", "");
                if (pageSource.Contains("permalink-inner permalink-tweet-container"))
                {
                    string TweetUserId = globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pageSource, "div", "permalink-inner permalink-tweet-container");

                    if (TweetUserId.Contains("data-user-id="))
                    {
                        try
                        {
                            string tweetUserId1 = TweetUserId.Substring(TweetUserId.IndexOf("data-user-id="), TweetUserId.IndexOf(" ", TweetUserId.IndexOf("data-user-id=")) - TweetUserId.IndexOf("data-user-id=")).Replace("data-user-id=", string.Empty).Replace("\"", string.Empty).Trim();
                            lstTweetId.Add(tweetUserId1);
                        }
                        catch
                        {
                        }
                    }
                }
            }
            catch
            {
            }
            lstTweetId = lstTweetId.Distinct().ToList();
            return lstTweetId;
        }
Ejemplo n.º 7
0
        private List<string> GetTweetUserName(Globussoft.GlobusHttpHelper globusHttpHelper, string pageSource)
        {
            List<string> lstTweetUserName = new List<string>();
            try
            {
                //string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri(url), "", "");
                if (pageSource.Contains("permalink-inner permalink-tweet-container"))
                {
                    // string[] arrTweetUsername = Regex.Split(pageSource, "permalink-inner permalink-tweet-container");
                    string TweetUserName = globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pageSource, "div", "permalink-inner permalink-tweet-container");
                    if (TweetUserName.Contains("username js-action-profile-name"))
                    {
                        List<string> lst_TweetUserName = globusHttpHelper.GetTextDataByTagAndAttributeName(TweetUserName, "span", "username js-action-profile-name");
                        lstTweetUserName.AddRange(lst_TweetUserName);
                    }

                }
            }
            catch
            {
            }
            lstTweetUserName = lstTweetUserName.Distinct().ToList();
            return lstTweetUserName;
        }
Ejemplo n.º 8
0
        private List<string> GetstatusId(string pagesource, Globussoft.GlobusHttpHelper globusHttpHelper, ref string screenName)
        {

            List<string> lstStatusId = new List<string>();
            try
            {
                string contentMain=globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pagesource,"div","content-main");
                //Log("Starting GetstatusId..............With User Name : " + UserName);

                string[] arrStatusId = Regex.Split(contentMain, "href=");
                foreach (string item in arrStatusId)
                {
                    try
                    {
                        if (!item.Contains("<div class=\"content-main\" id=\"timeline\">") && item.Contains("/status/"))
                        {


                            string statusId = string.Empty;
                            string statusIdValue = item.Substring(0, 100);
                            string href = string.Empty;

                            if (statusIdValue.Contains("/status/"))
                            {
                                if (statusIdValue.Contains("&"))
                                {
                                    try
                                    {
                                        href = statusIdValue.Substring(statusIdValue.IndexOf("/"), statusIdValue.IndexOf("&", statusIdValue.IndexOf("/")) - statusIdValue.IndexOf("/")).Trim();
                                        lstHref.Add(href);
                                        lstHref = lstHref.Distinct().ToList();

                                        statusId = statusIdValue.Substring(statusIdValue.IndexOf("/status/"), statusIdValue.IndexOf("&", statusIdValue.IndexOf("/status/")) - statusIdValue.IndexOf("/status/")).Replace("/status/", string.Empty).Trim();
                                        string[] arrCheckStatusId = Regex.Split(statusId, "[a-zA-Z]");
                                        lstStatusId.Add(arrCheckStatusId[0]);
                                    }
                                    catch
                                    {
                                    }
                                }
                                else
                                {
                                    try
                                    {
                                        href = statusIdValue.Substring(statusIdValue.IndexOf("/"), statusIdValue.IndexOf("\"", statusIdValue.IndexOf("/")) - statusIdValue.IndexOf("/")).Trim();
                                        lstHref.Add(href);
                                        lstHref = lstHref.Distinct().ToList();
                                        
                                        statusId = statusIdValue.Substring(statusIdValue.IndexOf("/status/"), statusIdValue.IndexOf("\"", statusIdValue.IndexOf("/status/")) - statusIdValue.IndexOf("/status/")).Replace("/status/", string.Empty).Trim();
                                        string[] arrCheckStatusId = Regex.Split(statusId, "[a-zA-Z]");
                                        lstStatusId.Add(arrCheckStatusId[0]);
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                           
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch
            {
            }
            lstStatusId = lstStatusId.Distinct().ToList();

            //Log("Total StatusId = "+lstStatusId.Count +" With User Name : "+UserName);

            return lstStatusId;
        }
Ejemplo n.º 9
0
        public void GetMentions(ref Globussoft.GlobusHttpHelper globusHttpHelper, ref string userId, ref string userName, ref string Screen_name, ref string postAuthenticityToken)
        {
            try
            {
                string tweetId = string.Empty;
                string tweetUserName = string.Empty;
                string tweetMessage = string.Empty;
                string maxId = string.Empty;

                Log("[ " + DateTime.Now + " ] => [ Starting Scrap Mentions.............With User Name : " + UserName + " ]");

                string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/mentions"), "", "");

                DataSet ds_BeforeInsertionCount = obj_clsDB_Randomiser.SelectAllfromtb_RandomiserMention();
                int countBeforeInsertion = ds_BeforeInsertionCount.Tables["tb_RandomiserMention"].Rows.Count;

                if (pageSource.Contains("stream-container "))
                {
                    string streamContainer = globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pageSource, "div", "stream-container ");

                    string[] arrContent=Regex.Split(streamContainer, "content");

                    foreach (string item in arrContent)
                    {
                        try
                        {
                            if (item.Contains("username js-action-profile-name"))
                            {
                                try
                                {
                                    List<string> lst_TweetUserName = globusHttpHelper.GetTextDataByTagAndAttributeName(item, "span", "username js-action-profile-name");

                                    if (lst_TweetUserName.Count > 0)
                                    {
                                        foreach (string item2 in lst_TweetUserName)
                                        {
                                            try
                                            {
                                                if(!string.IsNullOrEmpty(item2))
                                                {
                                                    tweetUserName = item2;
                                                    break;
                                                }
                                            }
                                            catch
                                            {
                                            }
                                        }
                                    }
	
                                }
                                catch
                                {
                                }
                            }

                            if (item.Contains("js-tweet-text"))
                            {
                                try
                                {
                                    List<string> lstTweetReply = globusHttpHelper.GetTextDataByTagAndAttributeName(item, "p", "js-tweet-text");

                                    if (lstTweetReply.Count > 0)
                                    {
                                        foreach (string item3 in lstTweetReply)
                                        {
                                            try
                                            {
                                                if (!string.IsNullOrEmpty(item3))
                                                {
                                                    tweetMessage = item3;
                                                }
                                            }
                                            catch
                                            {
                                            }
                                        }
                                    }
                                }
                                catch
                                {
                                }
                            }

                            if (item.Contains("data-user-id="))
                            {
                                try
                                {
                                    string tweetUserId1 = item.Substring(item.IndexOf("data-user-id="), item.IndexOf(" ", item.IndexOf("data-user-id=")) - item.IndexOf("data-user-id=")).Replace("data-user-id=", string.Empty).Replace("\"", string.Empty).Trim();

                                    string[] ArrtweetUserId = Regex.Split(tweetUserId1, "[^0-9]");

                                    foreach (string item1 in ArrtweetUserId)
                                    {
                                        try
                                        {
                                            if (item1.Length > 3)
                                            {
                                                tweetId = item1;
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                                catch
                                {
                                }
                            }

                            if (item.Contains("data-max-id="))
                            {
                                try
                                {
                                    string data_max_id = item.Substring(item.IndexOf("data-max-id="), item.IndexOf(" ", item.IndexOf("data-max-id=")) - item.IndexOf("data-max-id=")).Replace("data-max-id=", string.Empty).Replace("\"", string.Empty).Trim();

                                    string[] arrdata_max_id = Regex.Split(data_max_id, "[^0-9]");

                                    foreach (string item4 in arrdata_max_id)
                                    {
                                        try
                                        {
                                            if (item4.Length > 3)
                                            {
                                                maxId = item4;
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                                catch
                                {
                                }
                            }
                        }
                        catch
                        {
                        }

                        
                        DataSet ds2 = obj_clsDB_Randomiser.Selecttb_RandomiserMention(UserName, tweetUserName, tweetMessage);
                        if (ds2.Tables["tb_RandomiserMention"].Rows.Count < 1)
                        {

                            if (!string.IsNullOrEmpty(tweetUserName))
                            {
                                obj_clsDB_Randomiser.Mention_InsertIntotb_RandomiserMention(StringEncoderDecoder.Encode(userName), StringEncoderDecoder.Encode(Screen_Name), StringEncoderDecoder.Encode(tweetId), StringEncoderDecoder.Encode(tweetUserName), StringEncoderDecoder.Encode(tweetMessage));

                                Log("[ " + DateTime.Now + " ] => [ " + count + "Record Saved in Database With User Name : " + UserName + " ]");

                                count++;
                            }
                        }

                    }
                }

                DataSet ds_AfterInsertionCount = obj_clsDB_Randomiser.SelectAllfromtb_RandomiserMention();
                int countAfterInsertion = ds_AfterInsertionCount.Tables["tb_RandomiserMention"].Rows.Count;

                if (countBeforeInsertion == countAfterInsertion)
                {
                    Log("[ " + DateTime.Now + " ] => [ There Is No New Mentions With User Name : " + UserName + " ]");
                }

                /// Ajax Request
                GetMentions_ThroughAjax(ref globusHttpHelper, ref userId, ref userName, ref Screen_name, ref postAuthenticityToken, maxId);

                Log("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED With User Name : " + UserName + " ]");
                Log("------------------------------------------------------------------------------------------------------------------------------------------");

            }
            catch
            {
            }
        }