Пример #1
0
        public void StartInBoardProGetDataWithPagination(ref GlobusHttpHelper HttpHelper)
        {
            #region Login
            try
            {
                //Temprary class
                //======================================================
                //string tempurl = "http://www.linkedin.com/profile/view?id=224916256&authType=OUT_OF_NETWORK&authToken=SWNz&locale=en_US&srchid=3387141351401255871148&srchindex=1&srchtotal=2017&trk=vsrp_people_res_name&trkInfo=VSRPsearchId%3A3387141351401255871148%2CVSRPtargetId%3A224916256%2CVSRPcmpt%3Aprimary";
                //CrawlingLinkedInPage(tempurl, ref HttpHelper);
                //======================================================
                if (SearchCriteria.AccountType == "RecuiterType")
                {
                    string pageSourceaAdvanceSearch = HttpHelper.getHtmlfromUrl1(new Uri("https://www.linkedin.com/recruiter/search"));
                    string referralUrl = string.Empty;
                    if (pageSourceaAdvanceSearch.Contains("csrfToken"))
                    {
                        try
                        {
                            int pagenumberrecruiter = 0;
                            bool IsShowLoggerPagecount = true;
                            int i = 1;
                            int startCount = 0;

                            #region seniorLevel
                            string tempSeniorlevel = string.Empty;
                            if (SearchCriteria.SeniorLevel.Contains(","))
                            {
                                string[] arrseniorLevel = Regex.Split(SearchCriteria.SeniorLevel, ",");
                                if (arrseniorLevel.Count() > 1)
                                {
                                    foreach (string item in arrseniorLevel)
                                    {
                                        tempSeniorlevel += "&facet.SE=" + item;
                                    }
                                }
                                else
                                {
                                    tempSeniorlevel = "&facet.SE=";
                                }
                            }
                            else if (string.IsNullOrEmpty(SearchCriteria.SeniorLevel))
                            {
                                tempSeniorlevel = "&facet.SE=";
                            }
                            else
                            {
                                tempSeniorlevel = "&facet.SE=" + SearchCriteria.SeniorLevel;
                            }
                            #endregion

                            #region Function
                            string tempFunction = string.Empty;
                            if (SearchCriteria.Function.Contains(","))
                            {
                                string[] arrFunction = Regex.Split(SearchCriteria.Function, ",");
                                if (arrFunction.Count() > 1)
                                {
                                    foreach (string item in arrFunction)
                                    {
                                        tempFunction += "&facet.FA=" + item;
                                    }
                                }
                                else
                                {
                                    tempFunction = "&facet.FA=";
                                }
                            }
                            else if (string.IsNullOrEmpty(SearchCriteria.Function))
                            {
                                tempFunction = "&facet.FA=";
                            }
                            else
                            {
                                tempFunction = "&facet.FA=" + SearchCriteria.Function;
                            }
                            #endregion

                            #region RelationShip
                            string tempRelationShip = string.Empty;
                            if (SearchCriteria.Relationship.Contains(","))
                            {
                                string[] arrRelationShip = Regex.Split(SearchCriteria.Relationship, ",");
                                if (arrRelationShip.Count() > 1)
                                {
                                    foreach (string item in arrRelationShip)
                                    {
                                        tempRelationShip += "&facet.N=" + item;
                                    }
                                }
                                else
                                {
                                    tempRelationShip = "&facet.N=";
                                }
                            }
                            else if (string.IsNullOrEmpty(SearchCriteria.Relationship))
                            {
                                tempRelationShip = "&facet.N=";
                            }
                            else
                            {
                                tempRelationShip = "&facet.N=" + SearchCriteria.Relationship;
                            }
                            #endregion

                            #region Language
                            string tempLanguage = string.Empty;
                            if (SearchCriteria.language.Contains(","))
                            {
                                string[] arrLanguage = Regex.Split(SearchCriteria.language, ",");
                                if (arrLanguage.Count() > 1)
                                {
                                    foreach (string item in arrLanguage)
                                    {
                                        tempLanguage += "&facet.L=" + item;
                                    }
                                }
                                else
                                {
                                    tempLanguage = "&facet.L=";
                                }
                            }
                            else if (string.IsNullOrEmpty(SearchCriteria.language))
                            {
                                tempLanguage = "&facet.L=";
                            }
                            else
                            {
                                tempLanguage = "&facet.L=" + SearchCriteria.language;
                            }
                            #endregion

                            #region Industry
                            string tempIndustry = string.Empty;
                            if (SearchCriteria.IndustryType.Contains(","))
                            {
                                string[] arrIndustry = Regex.Split(SearchCriteria.IndustryType, ",");
                                if (arrIndustry.Count() > 1)
                                {
                                    foreach (string item in arrIndustry)
                                    {
                                        tempIndustry += "&facet.L=" + item;
                                    }
                                }
                                else
                                {
                                    tempIndustry = "&facet.L=";
                                }
                            }
                            else if (string.IsNullOrEmpty(SearchCriteria.IndustryType))
                            {
                                tempIndustry = "&facet.L=";
                            }
                            else
                            {
                                tempIndustry = "&facet.L=" + SearchCriteria.IndustryType;
                            }
                            #endregion

                            #region Year of Experience
                            string tempExperience = string.Empty;
                            if (SearchCriteria.YearOfExperience.Contains(","))
                            {
                                string[] arrYearOfExperience = Regex.Split(SearchCriteria.YearOfExperience, ",");
                                if (arrYearOfExperience.Count() > 1)
                                {
                                    foreach (string item in arrYearOfExperience)
                                    {
                                        tempExperience += "&facet.TE=" + item;
                                    }
                                }
                                else
                                {
                                    tempExperience = "&facet.TE=";
                                }
                            }
                            else if (string.IsNullOrEmpty(SearchCriteria.YearOfExperience))
                            {
                                tempExperience = "&facet.TE=";
                            }
                            else
                            {
                                tempExperience = "&facet.TE=" + SearchCriteria.YearOfExperience;
                            }
                            #endregion

                            #region InterestedIN
                            string tempInteresedIn = string.Empty;
                            if (SearchCriteria.InerestedIn.Contains(","))
                            {
                                string[] arrInterestedIn = Regex.Split(SearchCriteria.InerestedIn, ",");
                                if (arrInterestedIn.Count() > 1)
                                {
                                    foreach (string item in arrInterestedIn)
                                    {
                                        tempInteresedIn += "&facet.P=" + item;
                                    }
                                }
                                else
                                {
                                    tempInteresedIn = "&facet.P=";
                                }
                            }
                            else if (string.IsNullOrEmpty(SearchCriteria.InerestedIn))
                            {
                                tempInteresedIn = "&facet.P=";
                            }
                            else
                            {
                                tempInteresedIn = "&facet.P=" + SearchCriteria.InerestedIn;
                            }
                            #endregion

                        StartAgain:

                            string recruiterUrl = string.Empty; //"https://www.linkedin.com/recruiter/api/search?keywords=" + Uri.EscapeDataString(SearchCriteria.Keyword) + "&page=" + i + "&start=" + startCount + "&count=25&countryCode=" + SearchCriteria.Country + "&postalCode=" + SearchCriteria.PostalCode + "&radiusMiles=" + SearchCriteria.within + "&jobTitle=" + SearchCriteria.Title + "&jobTitleTimeScope=" + SearchCriteria.TitleValue + "&company=" + SearchCriteria.Company + "&companyTimeScope=" + SearchCriteria.CompanyValue + "&firstName=" + SearchCriteria.FirstName + "&lastName=" + SearchCriteria.LastName + "&facet.TE=" + SearchCriteria.YearOfExperience + "&facet.CS=" + SearchCriteria.CompanySize + "&facet.L=" + SearchCriteria.language + "&facet.I=" + SearchCriteria.IndustryType + "&facet.FG=" + SearchCriteria.Group + "&facet.N=" + SearchCriteria.Relationship + "&facet.FA=" + SearchCriteria.Function + "&facet.SE=" + SearchCriteria.SeniorLevel + "&facet.P=" + SearchCriteria.InerestedIn + "&facet.F=" + SearchCriteria.Fortune1000 + "&facet.DR=" + SearchCriteria.RecentlyJoined + "&origin=ASAS"; //&facet.I=" + SearchCriteria.IndustryType + "&facet.FG=" + SearchCriteria.Group + "&facet.N=" + SearchCriteria.Relationship + "&facet.FA=" + SearchCriteria.Function + "&facet.SE=" + SearchCriteria.SeniorLevel + "&facet.P=" + SearchCriteria.InerestedIn + "&facet.F=" + SearchCriteria.Fortune1000 + "&facet.DR=" + SearchCriteria.RecentlyJoined + "
                            recruiterUrl = "https://www.linkedin.com/recruiter/api/search?keywords=" + Uri.EscapeDataString(SearchCriteria.Keyword) + "&page=" + i + "&start=" + startCount + "&count=25&countryCode=" + SearchCriteria.Country + "&postalCode=" + SearchCriteria.PostalCode + "&radiusMiles=" + SearchCriteria.within + "&jobTitle=" + SearchCriteria.Title + "&jobTitleTimeScope=" + SearchCriteria.TitleValue + "&company=" + SearchCriteria.Company + "&companyTimeScope=" + SearchCriteria.CompanyValue + "&firstName=" + SearchCriteria.FirstName + "&lastName=" + SearchCriteria.LastName + "" + tempExperience + "&facet.CS=" + SearchCriteria.CompanySize + "" + tempLanguage+ "" + tempIndustry + "&facet.FG=" + SearchCriteria.Group + "" + tempRelationShip + "" + tempFunction + "" + tempSeniorlevel + "" + tempInteresedIn + "&facet.F=" + SearchCriteria.Fortune1000 + "&facet.DR=" + SearchCriteria.RecentlyJoined + "&origin=ASAS"; //&facet.I=" + SearchCriteria.IndustryType + "&facet.FG=" + SearchCriteria.Group + "&facet.N=" + SearchCriteria.Relationship + "&facet.FA=" + SearchCriteria.Function + "&facet.SE=" + SearchCriteria.SeniorLevel + "&facet.P=" + SearchCriteria.InerestedIn + "&facet.F=" + SearchCriteria.Fortune1000 + "&facet.DR=" + SearchCriteria.RecentlyJoined + "
                            if (string.IsNullOrEmpty(SearchCriteria.Keyword))
                            {
                                recruiterUrl = recruiterUrl.Replace("keywords=", "");
                            }

                            if (string.IsNullOrEmpty(SearchCriteria.Country))
                            {
                                recruiterUrl = recruiterUrl.Replace("&countryCode=", "");
                            }

                            if (string.IsNullOrEmpty(SearchCriteria.PostalCode))
                            {
                                recruiterUrl = recruiterUrl.Replace("&postalCode=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.within))
                            {
                                recruiterUrl = recruiterUrl.Replace("&radiusMiles=", "");
                            }

                            if (string.IsNullOrEmpty(SearchCriteria.Title))
                            {
                                recruiterUrl = recruiterUrl.Replace("&jobTitle=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.TitleValue))
                            {
                                recruiterUrl = recruiterUrl.Replace("&jobTitleTimeScope=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.Company))
                            {
                                recruiterUrl = recruiterUrl.Replace("&company=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.CompanyValue))
                            {
                                recruiterUrl = recruiterUrl.Replace("&companyTimeScope=", "");
                            }

                            if (string.IsNullOrEmpty(SearchCriteria.FirstName))
                            {
                                recruiterUrl = recruiterUrl.Replace("&firstName=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.LastName))
                            {
                                recruiterUrl = recruiterUrl.Replace("&lastName=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.YearOfExperience))
                            {
                                recruiterUrl = recruiterUrl.Replace("&facet.TE=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.CompanySize))
                            {
                                recruiterUrl = recruiterUrl.Replace("&facet.CS=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.language))
                            {
                                recruiterUrl = recruiterUrl.Replace("&facet.L=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.IndustryType))
                            {
                                recruiterUrl = recruiterUrl.Replace("&facet.I=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.SeniorLevel))
                            {
                                recruiterUrl = recruiterUrl.Replace("&facet.SE=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.Function))
                            {
                                recruiterUrl = recruiterUrl.Replace("&facet.FA=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.Relationship))
                            {
                                recruiterUrl = recruiterUrl.Replace("&facet.N=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.InerestedIn))
                            {
                                recruiterUrl = recruiterUrl.Replace("&facet.P=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.Fortune1000))
                            {
                                recruiterUrl = recruiterUrl.Replace("&facet.F=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.Group))
                            {
                                recruiterUrl = recruiterUrl.Replace("&facet.FG=", "");
                            }
                            if (string.IsNullOrEmpty(SearchCriteria.RecentlyJoined))
                            {
                                recruiterUrl = recruiterUrl.Replace("&facet.DR=", "");
                            }

                            recruiterUrl = recruiterUrl.Trim();

                            referralUrl = "https://www.linkedin.com/recruiter/search?searchHistoryId=1256614203&searchCacheKey=226602fa-2763-48a7-a2ff-dfddc87c4840%2CIwQE&linkContext=Controller%3ApeopleSearch%2CAction%3AresultsWithFacets%2CID%3A1256614203&page=1&start=0&count=25";
                            string pageSourceaAdvanceSearch11 = string.Empty;

                            try
                            {
                                pageSourceaAdvanceSearch11 = HttpHelper.getHtmlfromUrlNewRefre(new Uri(recruiterUrl), referralUrl);
                            }
                            catch { }
                            string strTotalPageNO = string.Empty;

                            if (IsShowLoggerPagecount)
                            {
                                strTotalPageNO = Utils.getBetween(pageSourceaAdvanceSearch11, "total\":", ",").Trim();

                                try
                                {
                                    pagenumberrecruiter = int.Parse(strTotalPageNO);

                                    Log("[ " + DateTime.Now + " ] => [ Total Results :  " + pagenumberrecruiter + " ]");

                                }
                                catch (Exception)
                                {

                                }

                                pagenumberrecruiter = (pagenumberrecruiter / 25) + 1;

                                if (pagenumberrecruiter == -1)
                                {
                                    pagenumberrecruiter = 2;
                                }

                                if (pagenumberrecruiter == 1)
                                {
                                    pagenumberrecruiter = 2;
                                }

                                //if (IsShowLoggerPagecount)
                                {
                                    if (pagenumberrecruiter >= 1)
                                    {
                                        _HttpHelper = HttpHelper;

                                        if (!Globals.scrapeWithoutGoingToMainProfile)
                                        {
                                            new Thread(() =>
                                            {
                                                if (SearchCriteria.starter)
                                                {
                                                    string CheckString = string.Empty;
                                                    finalUrlCollectionForRecruter(CheckString);
                                                }

                                            }).Start();
                                        }
                                    }
                                }
                            }
                            IsShowLoggerPagecount = false;
                            while (i <= pagenumberrecruiter)
                            {
                                if (SearchCriteria.starter)
                                {

                                    if (pageSourceaAdvanceSearch11.Contains("memberId"))
                                    {
                                        try
                                        {
                                            List<string> PageSerchUrl = GettingAllUrlRecruiterType(pageSourceaAdvanceSearch11);
                                            PageSerchUrl.Distinct();

                                            if (PageSerchUrl.Count == 0)
                                            {
                                                Log("[ " + DateTime.Now + " ] => [ On the basis of your Account you can able to see " + RecordURL.Count + " Results ]");
                                                break;
                                            }

                                            foreach (string item in PageSerchUrl)
                                            {
                                                if (SearchCriteria.starter)
                                                {
                                                    if (item.Contains("recruiter/profile"))
                                                    {
                                                        try
                                                        {
                                                            string urlSerch = item;
                                                            if (urlSerch.Contains("recruiter/profile"))
                                                            {
                                                                RecordURL.Add(urlSerch);
                                                                if (!queRecordUrl.Contains(urlSerch))
                                                                {
                                                                    queRecordUrl.Enqueue(urlSerch);
                                                                }
                                                                RecordURL = RecordURL.Distinct().ToList();
                                                            }

                                                            try
                                                            {
                                                                Log("[ " + DateTime.Now + " ] => [ " + urlSerch + " ]");
                                                            }
                                                            catch { }
                                                        }
                                                        catch { }
                                                    }
                                                }
                                            }

                                            if (i == pagenumberrecruiter)
                                            {
                                                break;
                                            }

                                            startCount += 25; ;
                                            i++;
                                            Thread.Sleep(4000);
                                            goto StartAgain;
                                        }
                                        catch { }
                                    }

                                }
                            }
                            #region MyRegion

                            //string searchHistoryId = Utils.getBetween(pageSourceaAdvanceSearch, "searchHistoryId\":", ",").Replace("\"", "").Trim();
                           // string searchCacheKey = Utils.getBetween(pageSourceaAdvanceSearch, "searchCacheKey\":", ",\"").Replace("\"", "").Trim();
                            //string linkContext = Utils.getBetween(pageSourceaAdvanceSearch, "linkContext\":", ",\"").Replace("\"", "").Trim();
                            //referralUrl = "https://www.linkedin.com/recruiter/search?searchHistoryId=" + Uri.EscapeDataString(searchHistoryId) + "&searchCacheKey=" + Uri.EscapeDataString(searchCacheKey).Replace(",", "%2C") + "&linkContext=" + Uri.EscapeDataString(linkContext) + "&page=1&start=0&count=25";

                            //pageSourceaAdvanceSearch = HttpHelper.getHtmlfromUrl1(new Uri(referralUrl));
                            //searchHistoryId = Utils.getBetween(pageSourceaAdvanceSearch, "searchHistoryId\":", ",").Replace("\"", "").Trim();
                            //searchCacheKey = Utils.getBetween(pageSourceaAdvanceSearch, "searchCacheKey\":", ",\"").Replace("\"", "").Trim();
                            //linkContext = Utils.getBetween(pageSourceaAdvanceSearch, "linkContext\":", ",\"").Replace("\"", "").Trim();

                            //int startindex = pageSourceaAdvanceSearch.IndexOf("csrfToken");
                            //if (startindex > 0)
                            //{
                            //    string start = pageSourceaAdvanceSearch.Substring(startindex);
                            //    int endindex = start.IndexOf(">");
                            //    string end = start.Substring(0, endindex);
                            //    csrfToken = end.Replace("csrfToken=", "").Replace("\\", "").Replace("\"", string.Empty).Replace("%3A", ":"); ;
                            //}

                            //string postData = "{\"keywords\":\"hr\",\"locationParams\":{\"countryCode\":\"us\",\"postalCode\":[null]},\"metaParams\":{\"resetFacets\":true,\"reset\":[\"keywords\",\"countryCode\",\"postalCode\",\"company\",\"companyTimeScope\",\"jobTitle\",\"jobTitleTimeScope\",\"notes\",\"projects\",\"reviews\",\"reminders\"],\"origin\":\"GHDS\"},\"pagingParams\":{\"count\":1}}";
                            //postData = "{\"keywords\":\"hr\",\"locationParams\":{\"countryCode\":\"us\",\"postalCode\":[null]},\"metaParams\":{\"resetFacets\":true,\"reset\":[\"keywords\",\"countryCode\",\"postalCode\",\"company\",\"companyTimeScope\",\"jobTitle\",\"jobTitleTimeScope\",\"notes\",\"projects\",\"reviews\",\"reminders\"],\"origin\":\"GHDS\"},\"pagingParams\":{\"count\":1}}";

                            //string responsePostData = HttpHelper.postFormDataRefDemo(new Uri("https://www.linkedin.com/recruiter/search"), postData, referralUrl, csrfToken, "XMLHttpRequest", "", "https://www.linkedin.com", "");
                            //responsePostData = HttpHelper.postFormDataRefDemo(new Uri("https://www.linkedin.com/recruiter/search"), "", referralUrl, csrfToken, "", "XMLHttpRequest", "https://www.linkedin.com", "1");
                            //string demo = responsePostData;
                            #endregion

                        }
                        catch { }

                    }
                    return;

                }

                if (SearchCriteria.starter)
                {
                    #region Serch

                    string pageSourceaAdvanceSearch = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/search"));
                    NewSearchPage = string.Empty;

                    if (pageSourceaAdvanceSearch.Contains("csrfToken"))
                    {
                        try
                        {
                            int startindex = pageSourceaAdvanceSearch.IndexOf("csrfToken");
                            if (startindex > 0)
                            {
                                string start = pageSourceaAdvanceSearch.Substring(startindex);
                                int endindex = start.IndexOf(">");
                                string end = start.Substring(0, endindex);
                                csrfToken = end.Replace("csrfToken=", "").Replace("\\", "").Replace("\"", string.Empty); ;
                            }
                        }
                        catch { }

                    }

                    try
                    {
                        if (SearchCriteria.Location == "Y")
                        {
                            SearchCriteria.Country = string.Empty;
                        }

                        //if (NewSearchPage == string.Empty)
                        //{
                        //    string PostDataForPrimiumAccount = "csrfToken=" + csrfToken + "&keepFacets=true&pplSearchOrigin=ADVS&keywords=" + Uri.EscapeDataString(SearchCriteria.Keyword) + "&fname=" + SearchCriteria.FirstName + "&lname=" + SearchCriteria.LastName + "&companyScope=" + SearchCriteria.CompanyValue + "&searchLocationType=" + SearchCriteria.Location + "&countryCode=" + SearchCriteria.Country + "&postalCode=" + SearchCriteria.PostalCode + "&distance=" + SearchCriteria.within + "&title=&company=" + SearchCriteria.Company + "&currentCompany=" + SearchCriteria.CompanyValue + "&school=&I=" + SearchCriteria.IndustryType + "&FG=" + SearchCriteria.Group + "&N=" + SearchCriteria.Relationship + "&L=" + SearchCriteria.language + "&FA=" + SearchCriteria.Function + "&CS=" + SearchCriteria.CompanySize + "&SE=" + SearchCriteria.SeniorLevel + "&P=" + SearchCriteria.InerestedIn + "&TE=" + SearchCriteria.YearOfExperience + "&DR=" + SearchCriteria.RecentlyJoined + "&F=" + SearchCriteria.Fortune1000 + "&sortCriteria=R&viewCriteria=2&%2Fsearch%2Ffpsearch=Search";
                        //    ResponseWallPostForPremiumAcc = HttpHelper.postFormData(new Uri("http://www.linkedin.com/search/fpsearch"), PostDataForPrimiumAccount);
                        //}
                        //else
                        {
                            string GetDataForPrimiumAccount = string.Empty;
                            GetDataForPrimiumAccount = "http://www.linkedin.com/vsearch/p?openAdvancedForm=true&keywords=" + Uri.EscapeDataString(SearchCriteria.Keyword) + "&title=" + SearchCriteria.Title + "&titleScope=" + SearchCriteria.TitleValue + "&firstName=" + SearchCriteria.FirstName + "&lastName=" + SearchCriteria.LastName + "&postalCode=" + SearchCriteria.PostalCode + "&companyScope=" + SearchCriteria.CompanyValue + "&locationType=" + SearchCriteria.Location + "&countryCode=" + SearchCriteria.Country + "&company=" + SearchCriteria.Company + "&distance=" + SearchCriteria.within + "&f_FG=" + SearchCriteria.Group + "&f_L=" + SearchCriteria.language + "&f_N=" + SearchCriteria.Relationship + "&f_G=" + SearchCriteria.LocationArea + "&f_I=" + SearchCriteria.IndustryType + "&f_TE=" + SearchCriteria.YearOfExperience + "&f_FA=" + SearchCriteria.Function + "&f_SE=" + SearchCriteria.SeniorLevel + "&f_P=" + SearchCriteria.InerestedIn + "&f_CS=" + SearchCriteria.CompanySize + "&f_F=" + SearchCriteria.Fortune1000 + "&f_DR=" + SearchCriteria.RecentlyJoined + "&orig=ADVS";
                            ResponseWallPostForPremiumAcc = HttpHelper.getHtmlfromUrl1(new Uri(GetDataForPrimiumAccount));

                        }

                    }
                    catch { }

                    string facetsOrder = string.Empty;
                    if (PostResponce.Contains("facetsOrder"))
                    {
                        facetsOrder = ResponseWallPostForPremiumAcc.Substring(PostResponce.IndexOf("facetsOrder"), 200);
                        string[] Arr3 = facetsOrder.Split('"');
                        facetsOrder = Arr3[2];
                        string DecodedCharTest = Uri.UnescapeDataString(facetsOrder);
                        string DecodedEmail = Uri.EscapeDataString(facetsOrder);
                        facetsOrder = DecodedEmail;
                    }
                   #endregion
                }
                int pagenumber = 0;
                string strPageNumber = string.Empty;
                string[] Arr12 = Regex.Split(ResponseWallPostForPremiumAcc, "<li");
                foreach (string item in Arr12)
                {
                    if (SearchCriteria.starter)
                    {
                        #region Loop
                        if (!item.Contains("<!DOCTYPE"))
                        {
                            if (item.Contains("results-summary"))
                            {
                                string data = RemoveAllHtmlTag.StripHTML(item);
                                data = data.Replace("\n", "");
                                if (data.Contains(">"))
                                {
                                    string[] ArrTemp = data.Split('>');
                                    data = ArrTemp[1];
                                    data = data.Replace("results", "");
                                    data = data.Trim();
                                    string[] ArrTemp1 = data.Split(' ');
                                    data = ArrTemp1[0].Replace(',', ' ').Trim();
                                    strPageNumber = data.Replace(" ", string.Empty);
                                    break;
                                }

                            }
                        }
                        #endregion
                    }
                }

                if (string.IsNullOrEmpty(strPageNumber))
                {
                    try
                    {
                        if (ResponseWallPostForPremiumAcc.Contains("resultCount"))
                        {
                            string[] countResultArr = Regex.Split(ResponseWallPostForPremiumAcc, "resultCount");

                            if (countResultArr.Length > 1)
                            {
                                string tempResult = countResultArr[1].Substring(0, countResultArr[1].IndexOf(","));

                                #region Commented
                                //Regex IdCheck = new Regex("^[0-9]*$");

                                //string[] tempResultArr = Regex.Split(tempResult, "[^0-9]");

                                //foreach (string item in tempResultArr)
                                //{
                                //    try
                                //    {
                                //        if(IdCheck.IsMatch(item))
                                //        {
                                //            strPageNumber = item;

                                //            break;
                                //        }
                                //    }
                                //    catch (Exception ex)
                                //    {
                                //    }
                                //}
                                #endregion

                                if (tempResult.Contains("<strong>"))
                                {
                                    strPageNumber = tempResult.Substring(tempResult.IndexOf("<strong>"), tempResult.IndexOf("</strong>", tempResult.IndexOf("<strong>")) - tempResult.IndexOf("<strong>")).Replace("<strong>", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Trim();
                                }
                                else if (tempResult.Contains(":"))
                                {
                                    strPageNumber = tempResult.Replace(":", string.Empty).Replace("\"", string.Empty);
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {

                    }
                }

                if (string.IsNullOrEmpty(strPageNumber))
                {
                    try
                    {
                        if (ResponseWallPostForPremiumAcc.Contains("results_count_without_keywords_i18n"))
                        {
                            string[] countResultArr = Regex.Split(ResponseWallPostForPremiumAcc, "results_count_without_keywords_i18n");

                            if (countResultArr.Length > 1)
                            {
                                string tempResult = countResultArr[1].Substring(0, countResultArr[1].IndexOf(","));

                                if (tempResult.Contains("<strong>"))
                                {
                                    strPageNumber = tempResult.Substring(tempResult.IndexOf("<strong>"), tempResult.IndexOf("</strong>", tempResult.IndexOf("<strong>")) - tempResult.IndexOf("<strong>")).Replace("<strong>", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Trim();
                                }
                                else if (tempResult.Contains(":"))
                                {
                                    strPageNumber = tempResult.Replace(":", string.Empty).Replace("\"", string.Empty);
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {

                    }
                }

                string logtag = string.Empty;

                try
                {
                    pagenumber = int.Parse(strPageNumber);

                    Log("[ " + DateTime.Now + " ] => [ Total Results :  " + pagenumber + " ]");
                }
                catch (Exception)
                {

                }

                pagenumber = (pagenumber / 10) + 1;

                if (pagenumber == -1)
                {
                    pagenumber = 2;
                }

                if (pagenumber == 1)
                {
                    pagenumber = 2;
                }

                string GetResponce = string.Empty;
                string GetRequestURL = string.Empty;

                if (pagenumber >= 1)
                {
                    _HttpHelper = HttpHelper;

                    if (!Globals.scrapeWithoutGoingToMainProfile)
                    {
                        new Thread(() =>
                        {
                            if (SearchCriteria.starter)
                            {
                                string CheckString = string.Empty;
                                finalUrlCollection(CheckString);
                            }

                        }).Start();
                    }

                    for (int i = 1; i <= pagenumber; i++)
                    {
                        if (SearchCriteria.starter)
                        {
                            #region loop

                            if (ResponseWallPostForPremiumAcc.Contains("Account Type:</span> Basic"))
                            {
                                try
                                {
                                    PostRequestURL = "http://www.linkedin.com/search/hits";
                                    PostdataForPagination = "keywords=" + Uri.EscapeDataString(SearchCriteria.Keyword) + "&title=" + Uri.EscapeDataString(SearchCriteria.Title) + "&fname=" + SearchCriteria.FirstName + "&lname=" + SearchCriteria.LastName + "&searchLocationType=" + SearchCriteria.Location + "&f_FG=" + SearchCriteria.Group + "&companyScope=" + SearchCriteria.CompanyValue + "&countryCode=" + SearchCriteria.Country + "&company=" + SearchCriteria.Company + "&viewCriteria=1&sortCriteria=R&facetsOrder=CC%2CN%2CG%2CI%2CPC%2CED%2CL%2CFG%2CTE%2CFA%2CSE%2CP%2CCS%2CF%2CDR&page_num=" + i + "&openFacets=N%2CCC%2CG";
                                    PostResponce = HttpHelper.postFormData(new Uri(PostRequestURL), PostdataForPagination);
                                    //Temporosy code for client
                                    //GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Pagesource 3 >>>> " + PostResponce, Globals.Path_InBoardProGetDataPagesource);

                                }
                                catch { }
                            }
                            else if (ResponseWallPostForPremiumAcc.Contains("Account Type:</span> Executive"))
                            {
                                try
                                {
                                    PostRequestURL = "http://www.linkedin.com/search/hits";
                                    PostdataForPagination = "keywords=" + Uri.EscapeDataString(SearchCriteria.Keyword) + "&title=" + Uri.EscapeDataString(SearchCriteria.Title) + "&fname=" + SearchCriteria.FirstName + "&lname=" + SearchCriteria.LastName + "&searchLocationType=" + SearchCriteria.Location + "&f_FG=" + SearchCriteria.Group + "&companyScope=" + SearchCriteria.CompanyValue + "&countryCode=" + SearchCriteria.Country + "&keepFacets=keepFacets&I=" + SearchCriteria.IndustryType + "&SE=" + SearchCriteria.SeniorLevel + "&pplSearchOrigin=ADVS&viewCriteria=2&sortCriteria=R&facetsOrder=N%2CCC%2CI%2CPC%2CED%2CL%2CFG%2CTE%2CFA%2CSE%2CP%2CCS%2CF%2CDR%2CG&page_num=" + i + "&openFacets=N%2CCC%2CI";

                                    PostResponce = HttpHelper.postFormData(new Uri(PostRequestURL), PostdataForPagination);
                                    //Temporosy code for client
                                    //GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Pagesource 3 >>>> " + PostResponce, Globals.Path_InBoardProGetDataPagesource);
                                }
                                catch { }
                            }
                            else if (ResponseWallPostForPremiumAcc.Contains("openAdvancedForm=true"))
                            {
                                PostRequestURL = "http://www.linkedin.com/vsearch/p?";
                                PostdataForPagination = "keywords=" + Uri.EscapeDataString(SearchCriteria.Keyword) + "&title=" + Uri.EscapeDataString(SearchCriteria.Title) + "&titleScope=" + SearchCriteria.TitleValue + "&firstName=" + SearchCriteria.FirstName + "&lastName=" + SearchCriteria.LastName + "&postalCode=" + SearchCriteria.PostalCode + "&openAdvancedForm=true&companyScope=" + SearchCriteria.CompanyValue + "&locationType=" + SearchCriteria.Location + "&f_FG=" + SearchCriteria.Group + "&countryCode=" + SearchCriteria.Country + "&company=" + SearchCriteria.Company + "&distance=" + SearchCriteria.within + "&f_N=" + SearchCriteria.Relationship + "&f_G=" + SearchCriteria.LocationArea + "&f_I=" + SearchCriteria.IndustryType + "&f_TE=" + SearchCriteria.YearOfExperience + "&f_FA=" + SearchCriteria.Function + "&f_SE=" + SearchCriteria.SeniorLevel + "&f_P=" + SearchCriteria.InerestedIn + "&f_CS=" + SearchCriteria.CompanySize + "&f_F=" + SearchCriteria.Fortune1000 + "&f_DR=" + SearchCriteria.RecentlyJoined + "&orig=ADVS&page_num=" + i + "";
                                PostResponce = HttpHelper.postFormData(new Uri(PostRequestURL), PostdataForPagination);
                                //Temporosy code for client
                                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Pagesource 4 >>>> " + PostResponce, Globals.Path_InBoardProGetDataPagesource);
                            }
                            else
                            {
                                try
                                {
                                    PostRequestURL = "http://www.linkedin.com/search/hits";
                                    PostdataForPagination = "keywords=" + Uri.EscapeDataString(SearchCriteria.Keyword) + "&title=" + Uri.EscapeDataString(SearchCriteria.Title) + "&fname=" + SearchCriteria.FirstName + "&lname=" + SearchCriteria.LastName + "&searchLocationType=" + SearchCriteria.Location + "&f_FG=" + SearchCriteria.Group + "&countryCode=" + SearchCriteria.Country + "&viewCriteria=1&sortCriteria=R&facetsOrder=CC%2CN%2CG%2CI%2CPC%2CED%2CL%2CFG%2CTE%2CFA%2CSE%2CP%2CCS%2CF%2CDR&page_num=" + i + "&openFacets=N%2CCC%2CG";
                                    PostResponce = HttpHelper.postFormData(new Uri(PostRequestURL), PostdataForPagination);
                                }
                                catch { }
                            }

                            if (PostResponce.Contains("/profile/view?id"))
                            {

                                if (Globals.scrapeWithoutGoingToMainProfile)
                                {

                                    if (i > 10)
                                    {
                                        if(PostResponce.Contains("Upgrade your account to see more results"))
                                        {
                                            Log("[ " + DateTime.Now + " ] => [ Search result limit reached. ]");
                                            Log("[ " + DateTime.Now + " ] => [ PROCESS COMPLETE ]");
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        Log("[ " + DateTime.Now + " ] => [ Crawling search result page number : " + i + " ]");
                                        CrawlingProfileDataFromSearchPage(PostResponce, ref HttpHelper);
                                    }
                                }
                                else
                                {
                                    List<string> PageSerchUrl = GettingAllUrl(PostResponce);
                                    PageSerchUrl.Distinct();

                                    if (PageSerchUrl.Count == 0)
                                    {
                                        Log("[ " + DateTime.Now + " ] => [ On the basis of your Account you can able to see " + RecordURL.Count + " Results ]");
                                        break;
                                    }

                                    foreach (string item in PageSerchUrl)
                                    {
                                        if (SearchCriteria.starter)
                                        {
                                            if (item.Contains("pp_profile_photo_link") || item.Contains("vsrp_people_res_name") || item.Contains("profile/view?"))
                                            {
                                                try
                                                {
                                                    string urlSerch = item;
                                                    if (urlSerch.Contains("vsrp_people_res_name"))
                                                    {
                                                        RecordURL.Add(urlSerch);
                                                        if (!queRecordUrl.Contains(urlSerch))
                                                        {
                                                            queRecordUrl.Enqueue(urlSerch);
                                                        }
                                                        RecordURL = RecordURL.Distinct().ToList();
                                                    }

                                                    try
                                                    {
                                                        Log("[ " + DateTime.Now + " ] => [ " + urlSerch + " ]");
                                                    }
                                                    catch { }
                                                }
                                                catch { }
                                            }
                                        }
                                    }
                                }
                            }

                            else if (!PostResponce.Contains("pp_profile_name_link") && PostResponce.Contains("Custom views are no longer supported. Please select either Basic or Expanded view"))
                            {
                                break;
                            }

                            #endregion
                        }
                    }
                }
                #region For Else
                else
                {
                    if (!Globals.scrapeWithoutGoingToMainProfile)
                    {
                        if (SearchCriteria.starter)
                        {

                            #region loop
                            if (ResponseWallPostForPremiumAcc.Contains("/profile/view?id"))
                            {

                                List<string> PageSerchUrl = ChilkatBasedRegex.GettingAllUrls(ResponseWallPostForPremiumAcc, "profile/view?id");
                                if (PageSerchUrl.Count == 0)
                                {

                                    Log("[ " + DateTime.Now + " ] => [ On the basis of your Account or Your Input you can able to see " + RecordURL.Count + "  Results ]");

                                }

                                foreach (string item in PageSerchUrl)
                                {
                                    if (SearchCriteria.starter)
                                    {
                                        if (item.Contains("pp_profile_name_link"))
                                        {
                                            string urlSerch = "http://www.linkedin.com" + item;
                                            Log("[ " + DateTime.Now + " ] => [ " + urlSerch + " ]");
                                            RecordURL.Add(urlSerch);
                                            queRecordUrl.Enqueue(urlSerch);

                                        }
                                    }
                                }
                            }
                            #endregion
                        }
                    }

                }

                if (strPageNumber != string.Empty)
                {
                    if (strPageNumber != "0")
                    {
                        Log("-------------------------------------------------------------------------------------------------------------------------------");
                        Log("[ " + DateTime.Now + " ] => [ No Of Results Found >>> " + strPageNumber + " ]");
                    }
                }

                RecordURL.Distinct();
                //if (SearchCriteria.starter)
                //{
                //    finalUrlCollection(ref HttpHelper);
                //    //new Thread(() =>
                //    //{
                //    //    test();
                //    //}).Start();
                //}

            }

               #endregion

            catch { }
            #endregion
        }