public List<string> ExtractFriendIDs_URLSpecific(ref GlobusHttpHelper HttpHelper, ref string userID, string specificURL, ref List<string> lstFriend_Suggestions)
        {
            try
            {
                string pgSrc_HomePage = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/"));
                string ProFileURL = string.Empty;

                string UserId = string.Empty;

                #region Get User or Account ID
                if (pgSrc_HomePage.Contains("http://www.facebook.com/profile.php?id="))
                {
                    ///Modified Sumit [10-12-2011]
                    #region

                    int startIndx = pgSrc_HomePage.IndexOf("http://www.facebook.com/profile.php?id=");
                    int endIndx = pgSrc_HomePage.IndexOf("\"", startIndx + 1);
                    ProFileURL = pgSrc_HomePage.Substring(startIndx, endIndx - startIndx);
                    if (ProFileURL.Contains("&"))
                    {
                        string[] Arr = ProFileURL.Split('&');
                        ProFileURL = Arr[0];
                    }

                    #endregion
                }
                if (ProFileURL.Contains("http://www.facebook.com/profile.php?id="))
                {
                    UserId = ProFileURL.Replace("http://www.facebook.com/profile.php?id=", "");
                    if (UserId.Contains("&"))
                    {
                        UserId = UserId.Remove(UserId.IndexOf("&"));
                    }
                    //userID = UserId;
                }
                #endregion

                List<string> lstFriend_Requests = new List<string>();
                //List<string> lstFriend_Suggestions = new List<string>();

                string pgSrc_FriendsPage = HttpHelper.getHtmlfromUrl(new Uri(specificURL));

                ChilkatHttpHelpr chilkatHelpr = new ChilkatHttpHelpr();

                //List<string> aTags = chilkatHelpr.GetDataTag(pgSrc_FriendsPage, "a");

                //List<string> spanTags = chilkatHelpr.GetDataTag(pgSrc_FriendsPage, "span");

                List<string> requestProfileURLs_FR_Requests = chilkatHelpr.GetHrefsByTagAndAttributeName(pgSrc_FriendsPage, "span", "title fsl fwb fcb");
                lstFriend_Requests.AddRange(requestProfileURLs_FR_Requests);

                List<string> requestProfileURLs_FR_Suggestions = chilkatHelpr.GetElementsbyTagAndAttributeName(pgSrc_FriendsPage, "div", "title fsl fwb fcb", "id");
                lstFriend_Suggestions.AddRange(requestProfileURLs_FR_Suggestions);

                #region Old Code

                //if (pgSrc_FriendsPage.Contains("http://www.facebook.com/profile.php?id="))
                //{
                //    string[] arr = Regex.Split(pgSrc_FriendsPage, "href");
                //    foreach (string strhref in arr)
                //    {
                //        if (!strhref.Contains("<!DOCTYPE"))
                //        {
                //            if (strhref.Contains("profile.php?id"))
                //            {
                //                int startIndx = strhref.IndexOf("profile.php?id") + "profile.php?id".Length + 1;
                //                int endIndx = strhref.IndexOf("\"", startIndx);

                //                string profileID = strhref.Substring(startIndx, endIndx - startIndx);

                //                if (profileID.Contains("&"))
                //                {
                //                    profileID = profileID.Remove(profileID.IndexOf("&"));
                //                }
                //                if (profileID.Contains("\\"))
                //                {
                //                    profileID = profileID.Replace("\\", "");
                //                }
                //                lstFriend.Add(profileID);
                //            }
                //        }
                //    }
                //} 
                #endregion
                List<string> itemId = lstFriend_Requests.Distinct().ToList();
                return itemId;
            }
            catch (Exception)
            {
                return null;
            }
        }
Example #2
0
        public List<string> ExtractRequestSendFriendIDs_URLSpecific(ref GlobusHttpHelper HttpHelper, ref string userID, string specificURL, ref List<string> lstFriend_Suggestions)
        {
            try
            {
                string pgSrc_HomePage = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/"));
                string ProFileURL = string.Empty;

                string UserId = string.Empty;

                #region Get User or Account ID
                if (pgSrc_HomePage.Contains("http://www.facebook.com/profile.php?id="))
                {
                    ///Modified Sumit [10-12-2011]
                    #region

                    int startIndx = pgSrc_HomePage.IndexOf("http://www.facebook.com/profile.php?id=");
                    int endIndx = pgSrc_HomePage.IndexOf("\"", startIndx + 1);
                    ProFileURL = pgSrc_HomePage.Substring(startIndx, endIndx - startIndx);
                    if (ProFileURL.Contains("&"))
                    {
                        string[] Arr = ProFileURL.Split('&');
                        ProFileURL = Arr[0];
                    }

                    #endregion
                }
                if (ProFileURL.Contains("http://www.facebook.com/profile.php?id="))
                {
                    UserId = ProFileURL.Replace("http://www.facebook.com/profile.php?id=", "");
                    if (UserId.Contains("&"))
                    {
                        UserId = UserId.Remove(UserId.IndexOf("&"));
                    }
                    //userID = UserId;
                }
                #endregion

                List<string> lstFriend_Requests = new List<string>();
                //List<string> lstFriend_Suggestions = new List<string>();

                string pgSrc_FriendsPage = HttpHelper.getHtmlfromUrl(new Uri(specificURL));

                ChilkatHttpHelpr chilkatHelpr = new ChilkatHttpHelpr();

                //List<string> aTags = chilkatHelpr.GetDataTag(pgSrc_FriendsPage, "a");

                //List<string> spanTags = chilkatHelpr.GetDataTag(pgSrc_FriendsPage, "span");

                List<string> requestProfileURLs_FR_Requests = chilkatHelpr.GetHrefsByTagAndAttributeName(pgSrc_FriendsPage, "span", "title fsl fwb fcb");
                lstFriend_Requests.AddRange(requestProfileURLs_FR_Requests);

                List<string> requestProfileURLs_FR_Suggestions = chilkatHelpr.GetElementsbyTagAndAttributeName(pgSrc_FriendsPage, "div", "title fsl fwb fcb", "id");
                lstFriend_Suggestions.AddRange(requestProfileURLs_FR_Suggestions);

                #region Old Code

                if (pgSrc_FriendsPage.Contains("data-profileid="))
                {
                    string[] arr = Regex.Split(pgSrc_FriendsPage, "data-profileid=");
                    foreach (string strhref in arr)
                    {
                        if (!strhref.Contains("<!DOCTYPE"))
                        {
                                string profileID=Utils.getBetween(strhref, "\"", "\"");
                                lstFriend_Requests.Add(profileID);
                           
                        }
                    }
                } 
                #endregion
                int Count = 0;
                if (pgSrc_FriendsPage.Contains("pager_id="))
                {
                    string Pager_ID = Utils.getBetween(pgSrc_FriendsPage, "pager_id=", "\"");
                    string page = Utils.getBetween(pgSrc_FriendsPage, "more/?page=", "&amp;");
                    while (true)
                    {
                        Count = Count + 1;
                        pgSrc_FriendsPage = HttpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/friends/requests/outgoing/more/?page=" + page + "&page_size=10&pager_id=" + Pager_ID + "&__user="******"&__a=1&__dyn=7n8ahyj35zoSt2u6aAix90BCxO4oKAdBGfirWo8pojByUW5ogxd6K4bBxi&__req=b&__rev=1398717"));
                        if (!pgSrc_FriendsPage.Contains("pager_id=") || page == "6" || Count>=5)
                        {
                            break;
                        }
                        Pager_ID = Utils.getBetween(pgSrc_FriendsPage, "pager_id=", "\\\"");
                        page = Utils.getBetween(pgSrc_FriendsPage, "more\\/?page=", "&amp;");

                        if (pgSrc_FriendsPage.Contains("data-profileid="))
                        {
                            string[] arr = Regex.Split(pgSrc_FriendsPage, "data-profileid=");
                            arr = arr.Skip(1).ToArray();
                            foreach (string strhref in arr)
                            {
                                if (!strhref.Contains("for("))
                                {
                                    string profileID = Utils.getBetween(strhref, "\\\"", "\\\"");
                                    lstFriend_Requests.Add(profileID);

                                }
                            }
                        } 
                    }
                }
                List<string> itemId = lstFriend_Requests.Distinct().ToList();
                return itemId;
            }
            catch (Exception)
            {
                return null;
            }
        }