コード例 #1
0
        public static List<string> GetLatestTrendsFromTwiter()
        {
            ILog logger = LogManager.GetLogger(typeof(TwitterScrapeHelper));
            List<string> lstOfTrends = new List<string>();
            try
            {
                GlobusHttpHelper objGlobusHttpHelper = new GlobusHttpHelper();
                string homepageUrl = "https://twitter.com/";
                string trendsUrl = "https://twitter.com/i/trends?k=0b49e0976b&pc=true&personalized=false&show_context=true&src=module&woeid=23424977";

                string homePageResponse = objGlobusHttpHelper.getHtmlfromUrl(new Uri(trendsUrl), "", "");

                try
                {
                    string[] GetTrends = Regex.Split(homePageResponse, "data-trend-name=");
                    GetTrends = GetTrends.Skip(1).ToArray();
                    foreach (string item in GetTrends)
                    {
                        try
                        {
                            string trend = Utils.getBetween(item, "\"", "\\\"").Replace("&#39;", "'");
                            lstOfTrends.Add(trend);
                        }
                        catch (Exception ex)
                        {
                            //GlobusLogHelper.log.Error("Error Get Current Trends ==> " + ex.Message);
                            logger.Error("Error Get Current Trends ==> " + ex.Message);
                            logger.Error( ex.StackTrace);

                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("Error Get Current Trends ==> " + ex.Message);
                    logger.Error(ex.StackTrace);
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error Get Current Trends ==> " + ex.Message);
                logger.Error(ex.StackTrace);
            }
            return lstOfTrends;
        }
コード例 #2
0
        public string HttpUploadFile_AddaCover(ref GlobusHttpHelper HttpHelper, string userid, string url, string paramName, string contentType, string localImagePath, NameValueCollection nvc, string proxyAddress, int proxyPort, string proxyUsername, string proxyPassword)
        {

            #region PostData_ForUploadImage
            //-----------------------------68682554727644
            //Content-Disposition: form-data; name="fb_dtsg"

            //AQCLSjCH
            // -----------------------------68682554727644
            //Content-Disposition: form-data; name="pic"; filename="Hydrangeas.jpg"
            //Content-Type: image/jpeg

            //���� 
            #endregion


            bool isAddaCover = false;
            string responseStr = string.Empty;

            try
            {
                ////log.Debug(string.Format("Uploading {0} to {1}", file, url));
                //string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("");
                string boundary = "---------------------------" + DateTime.Now.Ticks.ToString();
                byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");

                gRequest = (HttpWebRequest)WebRequest.Create(url);
                gRequest.ContentType = "multipart/form-data; boundary=" + boundary;
                gRequest.Referer = "Referer: https://www.facebook.com/profile.php?id=" + userid + "&ref=tn_tnmn";
                gRequest.Method = "POST";
                gRequest.KeepAlive = true;
                gRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;

                ChangeProxy(proxyAddress, proxyPort, proxyUsername, proxyPassword);

                gRequest.CookieContainer = new CookieContainer(); //gCookiesContainer;

                #region CookieManagment

                if (this.gCookies != null && this.gCookies.Count > 0)
                {
                    gRequest.CookieContainer.Add(gCookies);
                }
                #endregion

                Stream rs = gRequest.GetRequestStream();

                int tempi = 0;

                string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
                foreach (string key in nvc.Keys)
                {
                    string formitem = string.Empty;
                    if (tempi == 0)
                    {
                        byte[] firstboundarybytes = System.Text.Encoding.ASCII.GetBytes("--" + boundary + "\r\n");
                        rs.Write(firstboundarybytes, 0, firstboundarybytes.Length);
                        formitem = string.Format(formdataTemplate, key, nvc[key]);
                        byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
                        rs.Write(formitembytes, 0, formitembytes.Length);
                        tempi++;
                        continue;
                    }
                    //rs.Write(boundarybytes, 0, boundarybytes.Length);
                    //formitem = string.Format(formdataTemplate, key, nvc[key]);
                    //byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
                    //rs.Write(formitembytes, 0, formitembytes.Length);
                }
                rs.Write(boundarybytes, 0, boundarybytes.Length);

                string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n";
                string header = string.Format(headerTemplate, paramName, localImagePath, contentType);
                byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
                rs.Write(headerbytes, 0, headerbytes.Length);

                FileStream fileStream = new FileStream(localImagePath, FileMode.Open, FileAccess.Read);
                byte[] buffer = new byte[4096];
                int bytesRead = 0;
                while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
                {
                    rs.Write(buffer, 0, bytesRead);
                }
                fileStream.Close();

                byte[] trailer3 = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
                rs.Write(trailer3, 0, trailer3.Length);

                string trailerTemplate1 = "Content-Disposition: form-data; name=\"profile_id\"\r\n\r\n{0}\r\n";
                string trailer1 = string.Format(trailerTemplate1, userid);
                byte[] arrtrailer1 = System.Text.Encoding.UTF8.GetBytes(trailer1);
                rs.Write(arrtrailer1, 0, arrtrailer1.Length);

                byte[] trailer4 = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
                rs.Write(trailer4, 0, trailer3.Length);

                string trailerTemplate2 = "Content-Disposition: form-data; name=\"source\"\r\n\r\n{0}\r\n";
                string trailer2 = string.Format(trailerTemplate2, "10");
                byte[] arrtrailer2 = System.Text.Encoding.UTF8.GetBytes(trailer2);
                rs.Write(arrtrailer2, 0, arrtrailer2.Length);

                byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
                rs.Write(trailer, 0, trailer.Length);
                rs.Close();

                #region CookieManagment

                if (this.gCookies != null && this.gCookies.Count > 0)
                {
                    gRequest.CookieContainer.Add(gCookies);
                }

                #endregion

                WebResponse wresp = null;
                try
                {
                    wresp = gRequest.GetResponse();
                    Stream stream2 = wresp.GetResponseStream();
                    StreamReader reader2 = new StreamReader(stream2);
                    responseStr = reader2.ReadToEnd();
                    //log.Debug(string.Format("File uploaded, server response is: {0}", reader2.ReadToEnd()));
                    return responseStr;
                }
                catch (Exception ex)
                {
                    //log.Error("Error uploading file", ex);
                    if (wresp != null)
                    {
                        wresp.Close();
                        wresp = null;
                    }
                    // return false;
                }
            }
            catch (Exception ex)
            {
                //GlobusLogHelper.log.Error(ex.StackTrace);
            }

            finally
            {
                gRequest = null;
            }
            return responseStr;
        }
コード例 #3
0
        public bool AddaCover(ref GlobusHttpHelper HttpHelper, string Username, string Password, string localImagePath, string proxyAddress, string proxyPort, string proxyUsername, string proxyPassword, ref string status)
        {
            bool isAddaCover = false;
            string fb_dtsg = string.Empty;
            string photo_id = string.Empty;
            string UsreId = string.Empty;

            try
            {

                string pageSource_Home = HttpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/home.php"));

                UsreId = GlobusHttpHelper.GetParamValue(pageSource_Home, "user");
                if (string.IsNullOrEmpty(UsreId))
                {
                    UsreId = GlobusHttpHelper.ParseJson(pageSource_Home, "user");
                }

                fb_dtsg = GlobusHttpHelper.GetParamValue(pageSource_Home, "fb_dtsg");//pageSourceHome.Substring(pageSourceHome.IndexOf("fb_dtsg") + 16, 8);
                if (string.IsNullOrEmpty(fb_dtsg))
                {
                    fb_dtsg = GlobusHttpHelper.ParseJson(pageSource_Home, "fb_dtsg");
                }

                NameValueCollection nvc = new NameValueCollection();

                nvc.Add("fb_dtsg", fb_dtsg);
                //nvc.Add("filename=", fb_dtsg);
                nvc.Add("Content-Type:", "image/jpeg");

                string response = HttpUploadFile_AddaCover(ref HttpHelper, UsreId, "https://upload.facebook.com/ajax/timeline/cover/upload/", "pic", "image/jpeg", localImagePath, nvc, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);

                try
                {
               
                    string okay = HttpHelper.getHtmlfromUrl(new Uri("https://3-pct.channel.facebook.com/pull?channel=p" + UsreId + "&seq=3&partition=69&clientid=70e140db&cb=8p7w&idle=8&state=active&mode=stream&format=json"));
                }
                catch (Exception ex)
                {
                    //GlobusLogHelper.log.Error(ex.StackTrace);
                }

                if (!string.IsNullOrEmpty(response) && response.Contains("photo.php?fbid="))
                {
                    #region PostData_ForCoverPhotoSelect
                    //fb_dtsg=AQCLSjCH&photo_id=130869487061841&profile_id=100004163701035&photo_offset=0&video_id=&save=Save%20Changes&nctr[_mod]=pagelet_main_column_personal&__user=100004163701035&__a=1&phstamp=165816776831066772182 
                    #endregion
                    try
                    {
                        string photo_idValue = response.Substring(response.IndexOf("photo.php?fbid="), response.IndexOf(";", response.IndexOf("photo.php?fbid=")) - response.IndexOf("photo.php?fbid=")).Replace("photo.php?fbid=", string.Empty).Trim();
                        string[] arrphoto_idValue = Regex.Split(photo_idValue, "[^0-9]");

                        foreach (string item in arrphoto_idValue)
                        {
                            try
                            {
                                if (item.Length > 6)
                                {
                                    photo_id = item;
                                    break;
                                }
                            }
                            catch (Exception ex)
                            {
                                //GlobusLogHelper.log.Error(ex.StackTrace);
                            }
                        }

                        string postData = "fb_dtsg=" + fb_dtsg + "&photo_id=" + photo_id + "&profile_id=" + UsreId + "&photo_offset=0&video_id=&save=Save%20Changes&nctr[_mod]=pagelet_main_column_personal&__user="******"&__a=1&phstamp=165816776831066772182 ";
                        string postResponse = HttpHelper.postFormData(new Uri("https://www.facebook.com/ajax/timeline/cover_photo_select.php"), postData);

                        if (!postResponse.Contains("error"))
                        {
                            //string ok = "ok";
                            isAddaCover = true;
                        }
                        if (string.IsNullOrEmpty(postResponse) || string.IsNullOrWhiteSpace(postResponse))
                        {
                            status = "Response Is Null !";
                        }
                        if (postResponse.Contains("errorSummary"))
                        {
                            string summary = GlobusHttpHelper.ParseJson(postResponse, "errorSummary");
                            string errorDescription = GlobusHttpHelper.ParseJson(postResponse, "errorDescription");

                            status = "Posting Error: " + summary + " | Error Description: " + errorDescription;
                            //FanPagePosterLogger("Posting Error: " + summary + " | Error Description: " + errorDescription);
                        }
                    }
                    catch (Exception ex)
                    {
                        //GlobusLogHelper.log.Error(ex.StackTrace);
                    }
                }
                else
                {
                    if (response.Contains("Please choose an image that"))
                    {
                        status = "Please choose an image that's at least 399 pixels wide";
                    }

                }
            }
            catch (Exception ex)
            {
                //GlobusLogHelper.log.Error(ex.StackTrace);
            }
            return isAddaCover;
        }
コード例 #4
0
        public bool MultiPartImageUpload(ref GlobusHttpHelper httpHelper, string Username, string Password, string localImagePath, string proxyAddress, string proxyPort, string proxyUsername, string proxyPassword)
        {
            /////Login to FB

            ////string valueLSD = "name=" + "\"lsd\"";

            int intProxyPort = 80;

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

            if (!string.IsNullOrEmpty(proxyPort) && IdCheck.IsMatch(proxyPort))
            {
                intProxyPort = int.Parse(proxyPort);
            }
            //string pageSource = string.Empty;
            //try
            //{
            //    pageSource = getHtmlfromUrlProxy(new Uri("https://www.facebook.com/login.php"), proxyAddress, intProxyPort, proxyUsername, proxyPassword);
            //    //int startIndex = pageSource.IndexOf(valueLSD) + 18;
            //}
            //catch { }
            //string value = GlobusHttpHelper.GetParamValue(pageSource, "lsd");
            string ResponseLogin = string.Empty;
            try
            {
            //    ResponseLogin = postFormData(new Uri("https://www.facebook.com/login.php?login_attempt=1"), "charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&lsd=" + value + "&locale=en_US&email=" + Username.Split('@')[0] + "%40" + Username.Split('@')[1] + "&pass="******"&persistent=1&default_persistent=1&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&lsd=" + value + "");

                ResponseLogin = httpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com"));
            }
            catch { }
            ///Setting Post Data Params...

            string userId = GlobusHttpHelper.Get_UserID(ResponseLogin);

            if (string.IsNullOrEmpty(userId) || userId == "0" || userId.Length < 3)
            {
                //GlobusLogHelper.log.Info("Please Check The Account : " + Username);
                //GlobusLogHelper.log.Debug("Please Check The Account : " + Username);

                return false;
            }

            string pgSrc_Profile = string.Empty;
            try
            {
                pgSrc_Profile = httpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/profile.php?id=" + userId + ""));
            }
            catch { }
            string profileSource = string.Empty;
            try
            {
                profileSource = httpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/ajax/timeline/profile_pic_selector.php?profile_id=" + userId + "&__a=1&__user="******""));
            }
            catch { }


            //GlobusHttpHelper httpHelper = new GlobusHttpHelper();
            /////Get User ID
            //ProfileIDExtractor idExtracter = new ProfileIDExtractor();
            //idExtracter.ExtractFriendIDs(ref httpHelper, ref userId);


            string fb_dtsg = GlobusHttpHelper.GetParamValue(ResponseLogin, "fb_dtsg");//pageSourceHome.Substring(pageSourceHome.IndexOf("fb_dtsg") + 16, 8);
            if (string.IsNullOrEmpty(fb_dtsg))
            {
                fb_dtsg = GlobusHttpHelper.ParseJson(ResponseLogin, "fb_dtsg");
            }


            string last_action_id = GlobusHttpHelper.ParseJson(pgSrc_Profile, "last_action_id");

            if (!Utils.IsNumeric(last_action_id))
            {
                last_action_id = "0";
            }

            string postData = "last_action_id=" + last_action_id + "&fb_dtsg=" + fb_dtsg + "&__user="******"&phstamp=165816810252768712174";
            string res = string.Empty;
            try
            {
                res = httpHelper.postFormData(new Uri("https://www.facebook.com/ajax/mercury/thread_sync.php?__a=1"), postData);
            }
            catch { }
            NameValueCollection nvc = new NameValueCollection();
            //nvc.Add("post_form_id", post_form_id);
            nvc.Add("fb_dtsg", fb_dtsg);
            nvc.Add("id", userId);
            nvc.Add("type", "profile");
            //nvc.Add("return", "/ajax/profile/picture/upload_iframe.php?pic_type=1&id=" + userId);
            nvc.Add("return", "/ajax/timeline/profile_pic_upload.php?pic_type=1&id=" + userId);

            //UploadFilesToRemoteUrl("http://upload.facebook.com/pic_upload.php ", new string[] { @"C:\Users\Globus-n2\Desktop\Windows Photo Viewer Wallpaper.jpg" }, "", nvc);
            //HttpUploadFile("http://upload.facebook.com/pic_upload.php ", localImagePath, "file", "image/jpeg", nvc);
            if (HttpUploadFile("https://upload.facebook.com/pic_upload.php ", localImagePath, "pic", "image/jpeg", nvc, proxyAddress, intProxyPort, proxyUsername, proxyPassword))
            //if (HttpUploadFile("http://upload.facebook.com/pic_upload.php ", localImagePath, "file", "image/jpeg", nvc, proxyAddress, intProxyPort, proxyUsername, proxyPassword))
            {
                return true;
            }
            return false;

        }
コード例 #5
0
        //public string HttpUploadFile_UploadPic_temp(ref GlobusHttpHelper HttpHelper, string userid, string url, string paramName, string contentType, string localImagePath, NameValueCollection nvc, string referer, string proxyAddress, int proxyPort, string proxyUsername, string proxyPassword)
        //{


        //    bool isAddaCover = false;
        //    string responseStr = string.Empty;
        //    //foreach (var item in LstPicUrlsGroupCampaignManager)
        //    {

        //        try
        //        {
        //            ////log.Debug(string.Format("Uploading {0} to {1}", file, url));
        //            //string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("");
        //            string boundary = "---------------------------" + DateTime.Now.Ticks.ToString();//"-----------------------------" + DateTime.Now.Ticks.ToString();
        //            byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");

        //            gRequest = (HttpWebRequest)WebRequest.Create(url);
        //            gRequest.ContentType = "multipart/form-data; boundary=" + boundary;
        //            //gRequest.Referer = "Referer: https://www.facebook.com/profile.php?id=" + userid + "&ref=tn_tnmn";
        //            gRequest.Referer = referer;// "http://www.facebook.com/?sk=welcome";

        //            gRequest.Method = "POST";
        //            gRequest.KeepAlive = true;
        //            gRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;

        //            ChangeProxy(proxyAddress, proxyPort, proxyUsername, proxyPassword);

        //            gRequest.Headers.Add("X-SVN-Rev", "827944");
        //            gRequest.UserAgent = UserAgent;
        //            gRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

        //            gRequest.CookieContainer = new CookieContainer(); //gCookiesContainer;

        //            #region CookieManagment

        //            if (this.gCookies != null && this.gCookies.Count > 0)
        //            {
        //                gRequest.CookieContainer.Add(gCookies);
        //            }
        //            #endregion

        //            using (Stream rs = gRequest.GetRequestStream())
        //            {
        //                string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
        //                foreach (string key in nvc.Keys)
        //                {
        //                    rs.Write(boundarybytes, 0, boundarybytes.Length);
        //                    string formitem = string.Format(formdataTemplate, key, nvc[key]);
        //                    byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
        //                    rs.Write(formitembytes, 0, formitembytes.Length);
        //                }
        //                rs.Write(boundarybytes, 0, boundarybytes.Length);

        //                string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n";
        //                string header = string.Format(headerTemplate, paramName, localImagePath, contentType);
        //                byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
        //                rs.Write(headerbytes, 0, headerbytes.Length);

        //                using (FileStream fileStream = new FileStream(localImagePath, FileMode.Open, FileAccess.Read))
        //                {
        //                    byte[] buffer = new byte[4096];
        //                    int bytesRead = 0;
        //                    while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
        //                    {
        //                        rs.Write(buffer, 0, bytesRead);
        //                    }
        //                }
        //                byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
        //                rs.Write(trailer, 0, trailer.Length);
        //            }

        //            #region CookieManagment

        //            if (this.gCookies != null && this.gCookies.Count > 0)
        //            {
        //                gRequest.CookieContainer.Add(gCookies);
        //            }

        //            #endregion

        //            WebResponse wresp = null;
        //            try
        //            {
        //                wresp = gRequest.GetResponse();
        //                Stream stream2 = wresp.GetResponseStream();
        //                using (StreamReader reader2 = new StreamReader(stream2))
        //                {
        //                    responseStr = reader2.ReadToEnd();
        //                }
        //                return responseStr;
        //                //log.Debug(string.Format("File uploaded, server response is: {0}", reader2.ReadToEnd()));
        //                //return true;
        //            }
        //            catch (Exception ex)
        //            {
        //                //log.Error("Error uploading file", ex);
        //                if (wresp != null)
        //                {
        //                    wresp.Close();
        //                    wresp = null;
        //                }
        //                // return false;
        //            }
        //            finally
        //            {
        //                //gRequest = null;
        //            }



        //            //return responseStr;

        //        }
        //        catch { }

        //    }
        //    return responseStr;
        //} 
        #endregion

        public string HttpUploadFile_UploadPic_temp(ref GlobusHttpHelper HttpHelper, string userid, string url, string paramName, string contentType, List<string> localImagePath, NameValueCollection nvc, string referer, string proxyAddress, int proxyPort, string proxyUsername, string proxyPassword)
        {


            bool isAddaCover = false;
            string responseStr = string.Empty;
            //foreach (var item in localImagePath)
            {
                //continue;
                try
                {
                    ////log.Debug(string.Format("Uploading {0} to {1}", file, url));
                    //string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("");
                    string boundary = "---------------------------" + DateTime.Now.Ticks.ToString();//"-----------------------------" + DateTime.Now.Ticks.ToString();
                    byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");

                    gRequest = (HttpWebRequest)WebRequest.Create(url);
                    gRequest.ContentType = "multipart/form-data; boundary=" + boundary;
                    //gRequest.Referer = "Referer: https://www.facebook.com/profile.php?id=" + userid + "&ref=tn_tnmn";
                    gRequest.Referer = referer;// "http://www.facebook.com/?sk=welcome";

                    gRequest.Method = "POST";
                    gRequest.KeepAlive = true;
                    gRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;

                    ChangeProxy(proxyAddress, proxyPort, proxyUsername, proxyPassword);

                    gRequest.Headers.Add("X-SVN-Rev", "827944");
                    gRequest.UserAgent = UserAgent;
                    gRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

                    gRequest.CookieContainer = new CookieContainer(); //gCookiesContainer;

                    #region CookieManagment

                    if (this.gCookies != null && this.gCookies.Count > 0)
                    {
                        gRequest.CookieContainer.Add(gCookies);
                    }
                    #endregion

                    using (Stream rs = gRequest.GetRequestStream())
                    {
                        foreach (var Img_item in localImagePath)
                        {

                            string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
                            foreach (string key in nvc.Keys)
                            {
                                rs.Write(boundarybytes, 0, boundarybytes.Length);
                                string formitem = string.Format(formdataTemplate, key, nvc[key]);
                                byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
                                rs.Write(formitembytes, 0, formitembytes.Length);
                            }
                            rs.Write(boundarybytes, 0, boundarybytes.Length);

                            string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n";
                            string header = string.Format(headerTemplate, paramName, Img_item, contentType);
                            byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
                            rs.Write(headerbytes, 0, headerbytes.Length);



                            using (FileStream fileStream = new FileStream(Img_item, FileMode.Open, FileAccess.Read))
                            {
                                byte[] buffer = new byte[4096];
                                int bytesRead = 0;
                                while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
                                {
                                    rs.Write(buffer, 0, bytesRead);
                                }
                            }
                            byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
                            rs.Write(trailer, 0, trailer.Length);
                        }
                    }
                }
                catch (Exception ex)
                {
                    //GlobusLogHelper.log.Error(ex.StackTrace);
                }
            }




            #region CookieManagment

            if (this.gCookies != null && this.gCookies.Count > 0)
            {
                gRequest.CookieContainer.Add(gCookies);
            }

            #endregion

            WebResponse wresp = null;
            try
            {
                wresp = gRequest.GetResponse();
                Stream stream2 = wresp.GetResponseStream();
                using (StreamReader reader2 = new StreamReader(stream2))
                {
                    responseStr = reader2.ReadToEnd();
                }
                return responseStr;
                //log.Debug(string.Format("File uploaded, server response is: {0}", reader2.ReadToEnd()));
                //return true;
            }
            catch (Exception ex)
            {
                //log.Error("Error uploading file", ex);
                if (wresp != null)
                {
                    wresp.Close();
                    wresp = null;
                }
                // return false;
            }
            finally
            {
                //gRequest = null;
            }

            return responseStr;

        }
コード例 #6
0
        public string HttpUploadFile_UploadPic(ref GlobusHttpHelper HttpHelper, string userid, string url, string paramName, string contentType, List<string> localImagePath, NameValueCollection nvc, string referer, string proxyAddress, int proxyPort, string proxyUsername, string proxyPassword)
        {

            #region PostData_ForUploadImage
            //-----------------------------68682554727644
            //Content-Disposition: form-data; name="fb_dtsg"

            //AQCLSjCH
            // -----------------------------68682554727644
            //Content-Disposition: form-data; name="pic"; filename="Hydrangeas.jpg"
            //Content-Type: image/jpeg

            //���� 
            #endregion


            bool isAddaCover = false;
            string responseStr = string.Empty;

            try
            {
                ////log.Debug(string.Format("Uploading {0} to {1}", file, url));
                //string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("");
                string boundary = "---------------------------" + DateTime.Now.Ticks.ToString();//"-----------------------------" + DateTime.Now.Ticks.ToString();
                byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");

                gRequest = (HttpWebRequest)WebRequest.Create(url);
                gRequest.ContentType = "multipart/form-data; boundary=" + boundary;
                //gRequest.Referer = "Referer: https://www.facebook.com/profile.php?id=" + userid + "&ref=tn_tnmn";
                gRequest.Referer = referer;// "http://www.facebook.com/?sk=welcome";

                gRequest.Method = "POST";
                gRequest.KeepAlive = true;
                gRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;

                ChangeProxy(proxyAddress, proxyPort, proxyUsername, proxyPassword);

                gRequest.Headers.Add("X-SVN-Rev", "827944");
                gRequest.UserAgent = UserAgent;
                gRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

                gRequest.CookieContainer = new CookieContainer(); //gCookiesContainer;

                #region CookieManagment

                if (this.gCookies != null && this.gCookies.Count > 0)
                {
                    gRequest.CookieContainer.Add(gCookies);
                }
                #endregion

                using (Stream rs = gRequest.GetRequestStream())
                {

                    string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
                    foreach (string key in nvc.Keys)
                    {
                        if (nvc[key].Contains(","))
                        {
                            foreach (string item in nvc[key].Split(','))
                            {
                                rs.Write(boundarybytes, 0, boundarybytes.Length);
                                string formitem1 = string.Format(formdataTemplate, key, item);
                                byte[] formitembytes1 = System.Text.Encoding.UTF8.GetBytes(formitem1);
                                rs.Write(formitembytes1, 0, formitembytes1.Length);
                            }
                        }
                        else
                        {
                            rs.Write(boundarybytes, 0, boundarybytes.Length);
                            string formitem = string.Format(formdataTemplate, key, nvc[key]);
                            byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
                            rs.Write(formitembytes, 0, formitembytes.Length);
                        }
                       
                    }
                    rs.Write(boundarybytes, 0, boundarybytes.Length);

                    #region CodeCommented
                    //string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n";
                    //string header = string.Format(headerTemplate, paramName, localImagePath, contentType);
                    //byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
                    //rs.Write(headerbytes, 0, headerbytes.Length);

                    //using (FileStream fileStream = new FileStream(localImagePath, FileMode.Open, FileAccess.Read))
                    //{
                    //    byte[] buffer = new byte[4096];
                    //    int bytesRead = 0;
                    //    while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
                    //    {
                    //        rs.Write(buffer, 0, bytesRead);
                    //    }
                    //} 
                    #endregion

                    byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
                    rs.Write(trailer, 0, trailer.Length);
                }

                #region CookieManagment

                if (this.gCookies != null && this.gCookies.Count > 0)
                {
                    gRequest.CookieContainer.Add(gCookies);
                }

                #endregion

                try
                {
                    using (WebResponse wresp = gRequest.GetResponse())
                    {
                        //wresp = gRequest.GetResponse();
                        using (Stream stream2 = wresp.GetResponseStream())
                        {
                            using (StreamReader reader2 = new StreamReader(stream2))
                            {
                                response_ImageUpload = reader2.ReadToEnd();
                            }
                        }
                        //log.Debug(string.Format("File uploaded, server response is: {0}", reader2.ReadToEnd()));
                        return response_ImageUpload;
                    }
                }
                catch (Exception ex)
                {
                    //log.Error("Error uploading file", ex);
                    error_ImageUpload = ex.Message;
                }
                finally
                {
                    gRequest = null;
                }
                return response_ImageUpload;

                #region COmmentedCode
                //}

                //int tempi = 0;

                //string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
                //string formitem = string.Empty;
                //foreach (string key in nvc.Keys)
                //{

                //    if (tempi < 9)
                //    {
                //        byte[] firstboundarybytes = System.Text.Encoding.ASCII.GetBytes(boundary + "\r\n");
                //        rs.Write(firstboundarybytes, 0, firstboundarybytes.Length);
                //        formitem = formitem + string.Format(formdataTemplate, key, nvc[key]);
                //        byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
                //        rs.Write(formitembytes, 0, formitembytes.Length);
                //        tempi++;
                //        continue;
                //    }
                //    //rs.Write(boundarybytes, 0, boundarybytes.Length);
                //    //formitem = string.Format(formdataTemplate, key, nvc[key]);
                //    //byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
                //    //rs.Write(formitembytes, 0, formitembytes.Length);
                //}
                //rs.Write(boundarybytes, 0, boundarybytes.Length);

                //string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n";
                //string header = string.Format(headerTemplate, paramName, localImagePath, contentType);
                //byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
                //rs.Write(headerbytes, 0, headerbytes.Length);

                //FileStream fileStream = new FileStream(localImagePath, FileMode.Open, FileAccess.Read);
                //byte[] buffer = new byte[4096];
                //int bytesRead = 0;
                //while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
                //{
                //    rs.Write(buffer, 0, bytesRead);
                //}
                //fileStream.Close();

                //byte[] trailer3 = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
                //rs.Write(trailer3, 0, trailer3.Length);

                //string trailerTemplate1 = "Content-Disposition: form-data; name=\"profile_id\"\r\n\r\n{0}\r\n";
                //string trailer1 = string.Format(trailerTemplate1, userid);
                //byte[] arrtrailer1 = System.Text.Encoding.UTF8.GetBytes(trailer1);
                //rs.Write(arrtrailer1, 0, arrtrailer1.Length);

                //byte[] trailer4 = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
                //rs.Write(trailer4, 0, trailer3.Length);

                //string trailerTemplate2 = "Content-Disposition: form-data; name=\"source\"\r\n\r\n{0}\r\n";
                //string trailer2 = string.Format(trailerTemplate2, "10");
                //byte[] arrtrailer2 = System.Text.Encoding.UTF8.GetBytes(trailer2);
                //rs.Write(arrtrailer2, 0, arrtrailer2.Length);

                //byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
                //rs.Write(trailer, 0, trailer.Length);
                //rs.Close();

                //#region CookieManagment

                //if (this.gCookies != null && this.gCookies.Count > 0)
                //{
                //    gRequest.CookieContainer.Add(gCookies);
                //}

                //#endregion

                //    WebResponse wresp = null;
                //    try
                //    {
                //        wresp = gRequest.GetResponse();
                //        Stream stream2 = wresp.GetResponseStream();
                //        StreamReader reader2 = new StreamReader(stream2);
                //        responseStr = reader2.ReadToEnd();
                //        //log.Debug(string.Format("File uploaded, server response is: {0}", reader2.ReadToEnd()));
                //        return responseStr;
                //    }
                //    catch (Exception ex)
                //    {
                //        //log.Error("Error uploading file", ex);
                //        if (wresp != null)
                //        {
                //            wresp.Close();
                //            wresp = null;
                //        }
                //        // return false;
                //    }
                //}
                //catch
                //{
                //}

                //finally
                //{
                //    gRequest = null;
                //}
                //return responseStr; 
                #endregion

            }
            catch (Exception ex)
            {
                //GlobusLogHelper.log.Error(ex.StackTrace);
            }
            return responseStr;
        }
コード例 #7
0
       public bool AddaPicture2(ref GlobusHttpHelper HttpHelper, string Username, string Password, List<string> localImagePath, string proxyAddress, string proxyPort, string proxyUsername, string proxyPassword, string targeturl, string message, ref string status, string pageSource_Home, string xhpc_targetid, string xhpc_composerid, string message_text, string fb_dtsg, string UsreId, string pageSource, ref int tempCountMain)
       {
           {

               pageSource = HttpHelper.getHtmlfromUrl(new Uri(targeturl));
               int tempCount = 0;
           startAgain:

               bool isSentPicMessage = false;
               //string fb_dtsg = string.Empty;
               string photo_id = string.Empty;
               //string UsreId = string.Empty;
               //xhpc_composerid = string.Empty;
               //xhpc_targetid = string.Empty;
               //message_text = string.Empty;

               try
               {
                   #region commentedCode


                   //string pageSource_Home = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/home.php"));

                   //UsreId = GlobusHttpHelper.GetParamValue(pageSource_Home, "user");
                   //if (string.IsNullOrEmpty(UsreId))
                   //{
                   //    UsreId = GlobusHttpHelper.ParseJson(pageSource_Home, "user");
                   //}

                   //fb_dtsg = GlobusHttpHelper.GetParamValue(pageSource_Home, "fb_dtsg");//pageSourceHome.Substring(pageSourceHome.IndexOf("fb_dtsg") + 16, 8);
                   //if (string.IsNullOrEmpty(fb_dtsg))
                   //{
                   //    fb_dtsg = GlobusHttpHelper.ParseJson(pageSource_Home, "fb_dtsg");
                   //}


                   //string pageSource_HomeData = HttpHelper.getHtmlfromUrl(new Uri(targeturl));
                   //xhpc_composerid = GlobusHttpHelper.GetParamValue(pageSource_HomeData, "composerid");
                   //xhpc_targetid = GlobusHttpHelper.GetParamValue(pageSource_HomeData, "xhpc_targetid"); 
                   #endregion

                   NameValueCollection newnvcTEMP = new NameValueCollection();

                   string composer_session_id = "";

                   string tempresponse1 = "";
                   ///temp post
                   {
                       string source = "";
                       string profile_id = "";
                       string gridID = "";
                       //  string qn = string.Empty;

                       try
                       {
                           string Url = "https://www.facebook.com/ajax/composerx/attachment/media/upload/?composerurihash=1";
                           string posturl1 = "fb_dtsg=" + fb_dtsg + "&composerid=" + xhpc_composerid + "&targetid=" + xhpc_targetid + "&loaded_components[0]=maininput&loaded_components[1]=cameraicon&loaded_components[2]=withtaggericon&loaded_components[3]=placetaggericon&loaded_components[4]=mainprivacywidget&loaded_components[5]=cameraicon&loaded_components[6]=mainprivacywidget&loaded_components[7]=withtaggericon&loaded_components[8]=placetaggericon&loaded_components[9]=maininput&nctr[_mod]=pagelet_group_composer&__user="******"&__a=1&__dyn=7n88QoAMNoBwXAw&__req=i&phstamp=16581688688747595501";    //"fb_dtsg=" + fb_dtsg + "&composerid=" + xhpc_composerid + "&targetid=" + xhpc_targetid + "&istimeline=1&timelinelocation=composer&loaded_components[0]=maininput&loaded_components[1]=mainprivacywidget&loaded_components[2]=mainprivacywidget&loaded_components[3]=maininput&loaded_components[4]=explicitplaceinput&loaded_components[5]=hiddenplaceinput&loaded_components[6]=placenameinput&loaded_components[7]=hiddensessionid&loaded_components[8]=withtagger&loaded_components[9]=backdatepicker&loaded_components[10]=placetagger&loaded_components[11]=withtaggericon&loaded_components[12]=backdateicon&loaded_components[13]=citysharericon&nctr[_mod]=pagelet_timeline_recent&__user="******"&__a=1&__dyn=7n88QoAMNoBwXAw&__req=18&phstamp=1658168111112559866679";
                           // string PostUrl = "city_id=" + CityIDS1 + "&city_page_id=" + city_page_id + "&city_name=" + CityName1 + "&is_default=false&session_id=1362404125&__user="******"&__a=1&__dyn=798aD5z5ynU&__req=z&fb_dtsg=" + fb_dtsg + "&phstamp=1658168111112559866165";
                           string res11 = HttpHelper.postFormData(new Uri(Url), posturl1);


                           try
                           {
                               source = res11.Substring(res11.IndexOf("source\":"), (res11.IndexOf(",", res11.IndexOf("source\":")) - res11.IndexOf("source\":"))).Replace("source\":", string.Empty).Replace("<dd>", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();
                           }
                           catch { }
                           try
                           {
                               profile_id = res11.Substring(res11.IndexOf("profile_id\":"), (res11.IndexOf("}", res11.IndexOf("profile_id\":")) - res11.IndexOf("profile_id\":"))).Replace("profile_id\":", string.Empty).Replace("<dd>", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();
                               if (profile_id.Contains(","))
                               {
                                   profile_id = ParseEncodedJson(res11, "profile_id");
                               }
                               //"gridID":
                           }
                           catch { }
                           try
                           {
                               gridID = res11.Substring(res11.IndexOf("gridID\":"), (res11.IndexOf(",", res11.IndexOf("gridID\":")) - res11.IndexOf("gridID\":"))).Replace("gridID\":", string.Empty).Replace("<dd>", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();
                           }
                           catch { }
                           try
                           {
                               composer_session_id = res11.Substring(res11.IndexOf("composer_session_id\":"), (res11.IndexOf("}", res11.IndexOf("composer_session_id\":")) - res11.IndexOf("composer_session_id\":"))).Replace("composer_session_id\":", string.Empty).Replace("<dd>", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();
                           }
                           catch { }

                           try
                           {
                               if (string.IsNullOrEmpty(composer_session_id))
                               {
                                   composer_session_id = res11.Substring(res11.IndexOf("composerID\":"), (res11.IndexOf("}", res11.IndexOf("composerID\":")) - res11.IndexOf("composerID\":"))).Replace("composerID\":", string.Empty).Replace("<dd>", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();

                               }
                           }
                           catch { }

                           try
                           {
                               qn = getBetween(res11, "qn\\\" value=\\\"", "\\\" \\/>");
                           }
                           catch { }
                       }
                       catch { }

                       NameValueCollection nvc1 = new NameValueCollection();
                       try
                       {
                           //message = Uri.EscapeDataString(message);
                       }
                       catch { }

                       //xhpc_composerid = GlobusHttpHelper.GetParamValue(pageSource_HomeData, "composerid");
                       //xhpc_targetid = GlobusHttpHelper.GetParamValue(pageSource_HomeData, "xhpc_targetid");
                       //-------------------------------
                       //nvc1.Add("fb_dtsg", fb_dtsg);
                       //nvc1.Add("source", source);
                       //nvc1.Add("profile_id", profile_id);
                       //nvc1.Add("grid_id", gridID);
                       //nvc1.Add("upload_id", "1024");
                       //-----------------------------------
                       nvc1.Add("fb_dtsg", fb_dtsg);
                       nvc1.Add("source", source);
                       nvc1.Add("profile_id", profile_id);
                       nvc1.Add("grid_id", gridID);
                       nvc1.Add("upload_id", "1024");
                       nvc1.Add("qn", qn);

                       //nvc1.Add("fb_dtsg", fb_dtsg);
                       //nvc1.Add("source", source);
                       //nvc1.Add("profile_id", profile_id);
                       //nvc1.Add("grid_id", gridID);
                       //nvc1.Add("upload_id", "1024");
                       //nvc1.Add("qn", qn);

                       string _rev = getBetween(pageSource, "svn_rev", ",");
                       _rev = _rev.Replace("\":", string.Empty);


                       string uploadURL = "https://upload.facebook.com/ajax/composerx/attachment/media/saveunpublished?target_id=" + xhpc_targetid + "&__user="******"&__a=1&__dyn=7n88Oq9ccmqDxl2u5Fa8HzCqm5Aqbx2mbAKGiBAGm&__req=1t&fb_dtsg=" + fb_dtsg + "&__rev=" + _rev + "";
                      // string uploadURL = "https://upload.facebook.com/media/upload/photos/composer/?__user=100004602582421&__a=1&__dyn=7n88Oq9caRCFUSt2u5KIGKaExEW9J6yUgByVbGAEGGG&__req=12&fb_dtsg=AQDEsnKQ&ttstamp=2658168691151107581&__rev=1089685&";

                       //foreach (var item in collection)
                       //{

                       //}

                       foreach (string image in localImagePath)
                       {
                           tempresponse1 = HttpUploadFile_UploadPic_temp(ref HttpHelper, UsreId, uploadURL, "composer_unpublished_photo[]", "image/jpeg", image, nvc1, "", proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);

                           if (tempresponse1.ToLower().Contains("errorsummary") && tempresponse1.ToLower().Contains("There was a problem with this request. We're working on getting it fixed as soon as we can".ToLower()))
                           {
                               if (tempCount < 2)
                               {
                                   System.Threading.Thread.Sleep(15000);
                                   tempCount++;
                                   goto startAgain;
                               }
                               else
                               {
                                   tempCountMain++;
                                   return false;
                               }
                           }

                           //string response = HttpUploadFile_UploadPic(ref HttpHelper, UsreId, "https://upload.facebook.com/ajax/timeline/cover/upload/", "pic", "image/jpeg", localImagePath, nvc, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);

                           //string response = HttpUploadFile_UploadPic(ref HttpHelper, UsreId, "http://upload.facebook.com/media/upload/photos/composer/?__a=1&__adt=3&__iframe=true&__user="******"file1", "image/jpeg", localImagePath, nvc, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);

                           //tempresponse1 = HttpUploadFile_UploadPic_temp(ref HttpHelper, UsreId, "https://upload.facebook.com/ajax/composerx/attachment/media/saveunpublished?target_id=" + xhpc_targetid + "&__user="******"&__a=1&__dyn=7n88QoAMNoBwXAw&__req=l&fb_dtsg=" + fb_dtsg + "", "composer_unpublished_photo[]", "image/jpeg", localImagePath, nvc1, "", proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);

                           //composer_unpublished_photo
                           string composer_unpublished_photo = "";
                           string start_composer_unpublished_photo = Regex.Split(tempresponse1, "},\"")[1];// 

                           int startIndex_composer_unpublished_photo = start_composer_unpublished_photo.IndexOf(",\"") + ",\"".Length;
                           int endIndex_composer_unpublished_photo = start_composer_unpublished_photo.IndexOf("\"", startIndex_composer_unpublished_photo + 1);

                           composer_unpublished_photo = start_composer_unpublished_photo.Substring(startIndex_composer_unpublished_photo, endIndex_composer_unpublished_photo - startIndex_composer_unpublished_photo);



                           if (tempresponse1.Contains("composer_unpublished_photo"))
                           {
                               try
                               {
                                   composer_unpublished_photo = tempresponse1.Substring(tempresponse1.IndexOf("composer_unpublished_photo[]"), tempresponse1.IndexOf("u003Cbutton") - tempresponse1.IndexOf("composer_unpublished_photo[]")).Replace("composer_unpublished_photo[]", "").Replace("value=", "").Replace("\\", "").Replace("\\", "").Replace("/>", "").Replace("\"", "").Trim();
                                   //.Replace("composer_session_id\":", string.Empty).Replace("<dd>", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();
                               }
                               catch { }
                           }

                           newnvcTEMP.Add("composer_unpublished_photo[]", composer_unpublished_photo);
                       }
                       
                   }

                   NameValueCollection nvc = new NameValueCollection();
                   try
                   {
                       //message = Uri.EscapeDataString(message);
                   }
                   catch { }
                   nvc.Add("fb_dtsg", fb_dtsg);
                   nvc.Add("xhpc_targetid", xhpc_targetid);
                   nvc.Add("xhpc_context", "profile");
                   nvc.Add("xhpc_ismeta", "1");
                   nvc.Add("xhpc_fbx", "1");
                   nvc.Add("xhpc_timeline", "");
                   nvc.Add("xhpc_composerid", xhpc_composerid);
                   nvc.Add("xhpc_message_text", message);
                   nvc.Add("xhpc_message", message);
                   //nvc.Add("name", "file1");
                   //nvc.Add("Content-Type:", "image/jpeg");
                   //nvc.Add("filename=", "");


                   ////composer_unpublished_photo
                   //string composer_unpublished_photo = "";
                   //string start_composer_unpublished_photo = Regex.Split(tempresponse1, "},\"")[1];// 



                   //int startIndex_composer_unpublished_photo = start_composer_unpublished_photo.IndexOf(",\"") + ",\"".Length;
                   //int endIndex_composer_unpublished_photo = start_composer_unpublished_photo.IndexOf("\"", startIndex_composer_unpublished_photo + 1);

                   //composer_unpublished_photo = start_composer_unpublished_photo.Substring(startIndex_composer_unpublished_photo, endIndex_composer_unpublished_photo - startIndex_composer_unpublished_photo);

               
                   
                   //if (tempresponse1.Contains("composer_unpublished_photo"))
                   //{
                   //    try
                   //    {
                   //        composer_unpublished_photo = tempresponse1.Substring(tempresponse1.IndexOf("composer_unpublished_photo[]"), tempresponse1.IndexOf("u003Cbutton") - tempresponse1.IndexOf("composer_unpublished_photo[]")).Replace("composer_unpublished_photo[]", "").Replace("value=", "").Replace("\\", "").Replace("\\", "").Replace("/>", "").Replace("\"", "").Trim();
                   //        //.Replace("composer_session_id\":", string.Empty).Replace("<dd>", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();
                   //    }
                   //    catch { }
                   //}
                   ///New test upload pic post
                   ///
               
                



                   string waterfallid = GlobusHttpHelper.ParseJson(pageSource_Home, "waterfallID");

                   if (waterfallid.Contains("ar"))
                   {
                       waterfallid = qn;
                   }



                   string newpostURL = "https://upload.facebook.com/media/upload/photos/composer/?__user="******"&__a=1&__dyn=7n88QoAMNoBwXAw&__req=r&fb_dtsg=" + fb_dtsg + "";
                   string newPostData = "";


                   NameValueCollection newnvc = new NameValueCollection();
                   try
                   {
                       //message = Uri.EscapeDataString(message);
                   }
                   catch { }
                   newnvc.Add("fb_dtsg", fb_dtsg);
                   newnvc.Add("xhpc_targetid", xhpc_targetid);
                   newnvc.Add("xhpc_context", "profile");
                   newnvc.Add("xhpc_ismeta", "1");
                   newnvc.Add("xhpc_fbx", "1");
                   newnvc.Add("xhpc_timeline", "");
                   newnvc.Add("xhpc_composerid", xhpc_composerid);
                   newnvc.Add("xhpc_message_text", message);
                   newnvc.Add("xhpc_message", message);

                   newnvc.Add(newnvcTEMP);
                   //newnvc.Add("composer_unpublished_photo[]", composer_unpublished_photo);
                   newnvc.Add("album_type", "128");
                   newnvc.Add("is_file_form", "1");
                   newnvc.Add("oid", "");
                   newnvc.Add("qn", qn);//newnvc.Add("qn", waterfallid);
                   newnvc.Add("application", "composer");
                   newnvc.Add("is_explicit_place", "");
                   newnvc.Add("composertags_place", "");
                   newnvc.Add("composertags_place_name", "");
                   newnvc.Add("composer_session_id", composer_session_id);
                   newnvc.Add("composertags_city", "");
                   newnvc.Add("vzdisable_location_sharing", "false");
                   newnvc.Add("composer_predicted_city", "");



                   //string response = HttpUploadFile_UploadPic(ref HttpHelper, UsreId, newpostURL, "file1", "image/jpeg", localImagePath, newnvc, targeturl, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);//HttpUploadFile_UploadPic(ref HttpHelper, UsreId, "http://upload.facebook.com/media/upload/photos/composer/?__user="******"&__a=1&__dyn=7n88O49ccm9o-2Ki&__req=1c&fb_dtsg=" + fb_dtsg + "", "file1", "image/jpeg", localImagePath, nvc, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);
                   string response = HttpUploadFile_UploadPic(ref HttpHelper, UsreId, newpostURL, "file1", "image/jpeg", localImagePath, newnvc, targeturl, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);//HttpUploadFile_UploadPic(ref HttpHelper, UsreId, "http://upload.facebook.com/media/upload/photos/composer/?__user="******"&__a=1&__dyn=7n88O49ccm9o-2Ki&__req=1c&fb_dtsg=" + fb_dtsg + "", "file1", "image/jpeg", localImagePath, nvc, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);

                   try
                   {
                       string chek = HttpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/"));
                   }
                   catch { };
                   //http://upload.facebook.com/media/upload/photos/composer/?__a=1&__adt=3&__iframe=true&__user=100004608395129
                   if (string.IsNullOrEmpty(response))
                   {
                       try
                       {
                           //response = HttpUploadFile_UploadPic(ref HttpHelper, UsreId, "https://upload.facebook.com/media/upload/photos/composer/?__a=1&__adt=3&__iframe=true&__user="******"file1", "image/jpeg", localImagePath, nvc, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);
                           response = HttpUploadFile_UploadPic(ref HttpHelper, UsreId, "https://upload.facebook.com/media/upload/photos/composer/?__user="******"&__a=1&__dyn=7n88O49ccm9o-2Ki&__req=1c&fb_dtsg=" + fb_dtsg + "", "file1", "image/jpeg", localImagePath, nvc, targeturl, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);

                       }
                       catch { }
                   }
                   string posturl = "https://www.facebook.com/ajax/places/city_sharer_reset.php";
                   string postdata = "__user="******"&__a=1&fb_dtsg=" + fb_dtsg + "&phstamp=1658167761111108210145";
                   string responsestring = HttpHelper.postFormData(new Uri(posturl), postdata);
                   try
                   {
                       string okay = HttpHelper.getHtmlfromUrl(new Uri("https://3-pct.channel.facebook.com/pull?channel=p_" + UsreId + "&seq=3&partition=69&clientid=70e140db&cb=8p7w&idle=8&state=active&mode=stream&format=json"));
                   }
                   catch
                   {
                   }

                   if (!string.IsNullOrEmpty(response) && response.Contains("payload\":{\"photo_fbid"))//response.Contains("photo.php?fbid="))
                   {

                       #region PostData_ForCoverPhotoSelect
                       //fb_dtsg=AQCLSjCH&photo_id=130869487061841&profile_id=100004163701035&photo_offset=0&video_id=&save=Save%20Changes&nctr[_mod]=pagelet_main_column_personal&__user=100004163701035&__a=1&phstamp=165816776831066772182 
                       #endregion

                       try
                       {

                           if (!response.Contains("errorSummary") || !response.Contains("error"))
                           {
                               isSentPicMessage = true;
                           }
                           if (response.Contains("Your post has been submitted and is pending approval by an admin"))
                           {
                               //GlobusLogHelper.log.Debug("Your post has been submitted and is pending approval by an admin." + "GroupUrl >>>" + targeturl);
                               //GlobusLogHelper.log.Info("Your post has been submitted and is pending approval by an admin." + "GroupUrl >>>" + targeturl);
                           }
                       }
                       catch { }
                       #region CodeCommented
                       //    string photo_idValue = response.Substring(response.IndexOf("photo.php?fbid="), response.IndexOf(";", response.IndexOf("photo.php?fbid=")) - response.IndexOf("photo.php?fbid=")).Replace("photo.php?fbid=", string.Empty).Trim();
                       //    string[] arrphoto_idValue = Regex.Split(photo_idValue, "[^0-9]");

                       //    foreach (string item in arrphoto_idValue)
                       //    {
                       //        try
                       //        {
                       //            if (item.Length > 6)
                       //            {
                       //                photo_id = item;
                       //                break;
                       //            }
                       //        }
                       //        catch
                       //        {
                       //        }
                       //    }

                       //   // string postData = "fb_dtsg=" + fb_dtsg + "&photo_id=" + photo_id + "&profile_id=" + UsreId + "&photo_offset=0&video_id=&save=Save%20Changes&nctr[_mod]=pagelet_main_column_personal&__user="******"&__a=1&phstamp=165816776831066772182 ";
                       //   // string postResponse = HttpHelper.postFormData(new Uri("https://www.facebook.com/ajax/timeline/cover_photo_select.php"), postData);

                       //    //if (!postResponse.Contains("error"))
                       //    //{
                       //    //    //string ok = "ok";
                       //    //    isSentPicMessage = true;
                       //    //}
                       //    //if (string.IsNullOrEmpty(postResponse) || string.IsNullOrWhiteSpace(postResponse))
                       //    //{
                       //    //    status = "Response Is Null !";
                       //    //}
                       //    //if (postResponse.Contains("errorSummary"))
                       //    //{
                       //    //    string summary = GlobusHttpHelper.ParseJson(postResponse, "errorSummary");
                       //    //    string errorDescription = GlobusHttpHelper.ParseJson(postResponse, "errorDescription");

                       //    //    status = "Posting Error: " + summary + " | Error Description: " + errorDescription;
                       //    //    //FanPagePosterLogger("Posting Error: " + summary + " | Error Description: " + errorDescription);
                       //    //}
                       //}
                       //catch
                       //{
                       //} 
                       #endregion
                   }
               }
               catch
               {
               }
               return isSentPicMessage;
           }

       }
コード例 #8
0
        public static string GetPageID(string PageSrcFanPageUrl, ref string FanpageUrl)
        {
            #region Get FB Page ID Modified

            GlobusHttpHelper HttpHelper = new GlobusHttpHelper();

            string fbpage_id = string.Empty;

            try
            {
                if (PageSrcFanPageUrl.Contains("profile_owner"))
                {
                    fbpage_id = ParseEncodedJsonPageID(PageSrcFanPageUrl, "profile_owner");
                }

                if (string.IsNullOrEmpty(fbpage_id))
                {
                    if (PageSrcFanPageUrl.Contains("/feeds/page.php?id="))
                    {
                        int startIndxFeeds = PageSrcFanPageUrl.IndexOf("/feeds/page.php?id=") + "/feeds/page.php?id=".Length;
                        int endIndxFeeds = PageSrcFanPageUrl.IndexOf("\"", startIndxFeeds);
                        fbpage_id = PageSrcFanPageUrl.Substring(startIndxFeeds, endIndxFeeds - startIndxFeeds);

                        if (fbpage_id.Contains("&amp"))
                        {
                            fbpage_id = fbpage_id.Remove(fbpage_id.IndexOf("&amp"));
                        }
                    }
                    else if (PageSrcFanPageUrl.Contains("page.php?id="))
                    {
                        int startIndxFeeds = PageSrcFanPageUrl.IndexOf("/page.php?id=") + "/page.php?id=".Length;
                        int endIndxFeeds = PageSrcFanPageUrl.IndexOf("\"", startIndxFeeds);
                        fbpage_id = PageSrcFanPageUrl.Substring(startIndxFeeds, endIndxFeeds - startIndxFeeds);

                        if (fbpage_id.Contains("&amp"))
                        {
                            fbpage_id = fbpage_id.Remove(fbpage_id.IndexOf("&amp"));
                        }
                    }
                    else if (PageSrcFanPageUrl.Contains("php?page_id="))
                    {
                        int startIndxFeeds = PageSrcFanPageUrl.IndexOf("php?page_id=") + "php?page_id=".Length;
                        int endIndxFeeds = PageSrcFanPageUrl.IndexOf("\"", startIndxFeeds);
                        fbpage_id = PageSrcFanPageUrl.Substring(startIndxFeeds, endIndxFeeds - startIndxFeeds);

                        if (fbpage_id.Contains("&amp"))
                        {
                            fbpage_id = fbpage_id.Remove(fbpage_id.IndexOf("&amp"));
                        }
                    }
                    else
                    {
                        //FanPagePosterLogger("Unable To like Fan Page Wall with " + Username + " and " + FanpageUrl);
                        //return;
                    }


                    if (string.IsNullOrEmpty(fbpage_id))
                    {
                        fbpage_id = HttpHelper.ExtractIDUsingGraphAPI(FanpageUrl, ref HttpHelper);
                    }

                }
            }
            catch (Exception ex)
            {
                //GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
            }

            return fbpage_id;

            #endregion
        }
コード例 #9
0
 public string ExtractIDOfNonTimeLine(string URL, ref GlobusHttpHelper HttpHelper)
 {
     string id = "";
     try
     {
         string strURLPageSource = HttpHelper.getHtmlfromUrl(new Uri(URL));
         if (strURLPageSource.Contains("profile-picture-overlay"))
         {
             string[] arrprofile_picture_overlay = Regex.Split(strURLPageSource, "profile-picture-overlay");
             if (arrprofile_picture_overlay.Count() > 1)
             {
                 if (arrprofile_picture_overlay[1].Contains("?set="))
                 {
                     string strid = arrprofile_picture_overlay[1].Substring(arrprofile_picture_overlay[1].IndexOf("?set="), (arrprofile_picture_overlay[1].IndexOf("&amp", arrprofile_picture_overlay[1].IndexOf("?set=")) - arrprofile_picture_overlay[1].IndexOf("?set="))).Replace("?set=", string.Empty).Replace(".", "/").Trim();
                     string[] arrId = Regex.Split(strid, "/");
                     id = arrId.Last();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         //GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
     }
     return id;
 }
コード例 #10
0
        public string ExtractIDUsingGraphAPI(string URL, ref GlobusHttpHelper HttpHelper)
        {
            string profileID = string.Empty;

            try
            {
                if (URL.Contains("id="))
                {
                    profileID = URL.Replace(URL.Remove(URL.IndexOf("id=") + "id=".Length), "");
                    return profileID;
                }

                int startIndx = URL.LastIndexOf("/");
                string name = URL.Substring(startIndx).Replace("/", "");

                string response = HttpHelper.getHtmlfromUrl(new Uri("https://graph.facebook.com/" + name));
                profileID = ParseJsonGraphAPI(response, "id");
            }
            catch (Exception ex)
            {
                //GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
            }

            return profileID;
        }
コード例 #11
0
        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;
            }
        }
コード例 #12
0
        //public void ScraperHasTage(ref FacebookUser fbUser, string Hash, Guid BoardfbPageId)
        //{


        //    GlobusHttpHelper HttpHelper = fbUser.globusHttpHelper;
        //    string KeyWord = Hash;
        //    string pageSource_Home = HttpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/hashtag/" + KeyWord));
        //    List<string> pageSouceSplit = new List<string>();
        //    string[] trendingArr = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "li data-topicid=");
        //    string[] PagesLink = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "uiLikePageButton");
        //    foreach (var item in PagesLink)
        //    {
        //        pageSouceSplit.Add(item);
        //    }
        //    PagesLink = PagesLink.Skip(1).ToArray();

        //    foreach (var item_pageSouceSplit in pageSouceSplit)
        //    {
        //        try
        //        {
        //            if (item_pageSouceSplit.Contains("<!DOCTYPE html>"))
        //            {
        //                continue;
        //            }
        //            Dictionary<string, string> listContent = ScrapHasTagPages(item_pageSouceSplit);
        //            Domain.Socioboard.Domain.Boardfbfeeds fbfeed = new Domain.Socioboard.Domain.Boardfbfeeds();
        //            fbfeed.Id = Guid.NewGuid();
        //            fbfeed.Isvisible = true;
        //            fbfeed.Message = listContent["Message"];
        //            fbfeed.Image = listContent["PostImage"];
        //            fbfeed.Description = listContent["Title"];
        //            string[] splitdate = System.Text.RegularExpressions.Regex.Split(listContent["Time"], "at");
        //            string d = splitdate[0].Trim();
        //            string t = splitdate[1].Trim();
        //            fbfeed.Createddate = Convert.ToDateTime(d + " " + t);
        //            fbfeed.Feedid = listContent["PostId"];
        //            fbfeed.Type = listContent["Type"];
        //            fbfeed.Type = listContent["Link"];
        //            fbfeed.Fbpageprofileid = BoardfbPageId;
        //             if (!boardrepo.checkFacebookFeedExists(fbfeed.Feedid, BoardfbPageId))
        //             {
        //                 boardrepo.addBoardFbPageFeed(fbfeed);
        //             }

        //            // Please Write Code get Dictionary data 

        //            //


        //        }
        //        catch { };



        //    }


        //    try
        //    {


        //        string ajaxpipe_token = Utils.getBetween(pageSource_Home, "\"ajaxpipe_token\":\"", "\"");
        //        string[] data_c = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "data-cursor=");
        //        string cursor = Utils.getBetween(data_c[4], "\"", "=");
        //        if (cursor.Contains("data-dedupekey"))
        //        {
        //            cursor = "-" + cursor;
        //            cursor = Utils.getBetween(cursor, "-", "\"");
        //        }
        //        string sectionid = Utils.getBetween(pageSource_Home, "section_id\\\":", ",");
        //        string userid = Utils.getBetween(pageSource_Home, "USER_ID\":\"", "\"");
        //        string feed_Id = "90842368";
        //        string pager_id = "u_ps_0_0_1n";
        //        for (int i = 2; i < 50; i++)
        //        {
        //            try
        //            {
        //                Thread.Sleep(30 * 1000);

        //                List<string> pageSouceSplitPagination = new List<string>();
        //                if (string.IsNullOrEmpty(fbUser.username))
        //                {
        //                    break;
        //                }
        //                //GlobusLogHelper.log.Info("Please wait... Searching for data from Page :" + i + "   with User Name : " + fbUser.username);


        //                string req = "https://www.facebook.com/ajax/pagelet/generic.php/LitestandMoreStoriesPagelet?ajaxpipe=1&ajaxpipe_token=" + ajaxpipe_token + "&no_script_path=1&data=%7B%22cursor%22%3A%22" + cursor + "%22%2C%22preload_next_cursor%22%3Anull%2C%22pager_config%22%3A%22%7B%5C%22edge%5C%22%3Anull%2C%5C%22source_id%5C%22%3Anull%2C%5C%22section_id%5C%22%3A" + sectionid + "%2C%5C%22pause_at%5C%22%3Anull%2C%5C%22stream_id%5C%22%3Anull%2C%5C%22section_type%5C%22%3A1%2C%5C%22sizes%5C%22%3Anull%2C%5C%22most_recent%5C%22%3Afalse%2C%5C%22unread_session%5C%22%3Afalse%2C%5C%22continue_top_news_feed%5C%22%3Afalse%2C%5C%22ranking_model%5C%22%3Anull%2C%5C%22unread_only%5C%22%3Afalse%7D%22%2C%22pager_id%22%3A%22" + pager_id + "%22%2C%22scroll_count%22%3A1%2C%22start_unread_session%22%3Afalse%2C%22start_continue_top_news_feed%22%3Afalse%2C%22feed_stream_id%22%3A" + feed_Id + "%2C%22snapshot_time%22%3Anull%7D&__user="******"&__a=1&__dyn=7nm8RW8BgCBynzpQ9UoHaEWCueyrhEK49oKiWFaaBGeqrYw8popyujhElx2ubhHximmey8szoyfwgo&__req=jsonp_2&__rev=1583304&__adt=" + i + "";      //
        //                string respReq = HttpHelper.getHtmlfromUrl(new Uri(req));

        //                respReq = respReq.Replace("\\", "").Replace("u003C", "<");
        //                string[] arrrespReq = System.Text.RegularExpressions.Regex.Split(respReq, "source_id");
        //                feed_Id = Utils.getBetween(respReq, "feed_stream_id", "snapshot_time");
        //                feed_Id = Utils.getBetween(feed_Id, "A", "u");

        //                string[] pager_id1 = System.Text.RegularExpressions.Regex.Split(respReq, "_4-u2 mbl ");
        //                pager_id = Utils.getBetween(pager_id1[2], "id=\"", "\"");
        //                data_c = System.Text.RegularExpressions.Regex.Split(respReq, "data-cursor=");
        //                if (data_c.Length < 8)
        //                {
        //                    cursor = Utils.getBetween(data_c[data_c.Length - 1], "\"", "=");
        //                }
        //                cursor = Utils.getBetween(data_c[8], "\"", "=");
        //                if (cursor.Contains("data-dedupekey"))
        //                {
        //                    cursor = "-" + cursor;
        //                    cursor = Utils.getBetween(cursor, "-", "\"");
        //                }

        //                string[] PagesLinkPagination = System.Text.RegularExpressions.Regex.Split(respReq, "<span>Suggested Post</span>");

        //                foreach (var item in PagesLinkPagination)
        //                {
        //                    pageSouceSplitPagination.Add(item);
        //                }

        //                PagesLink = System.Text.RegularExpressions.Regex.Split(respReq, "uiLikePageButton");
        //                foreach (var item in PagesLink)
        //                {
        //                    pageSouceSplitPagination.Add(item);
        //                }


        //                foreach (var item_pageSouceSplit in pageSouceSplit)
        //                {
        //                    try
        //                    {
        //                        if (item_pageSouceSplit.Contains("<!DOCTYPE html>"))
        //                        {
        //                            continue;
        //                        }
        //                        Dictionary<string, string> listContent = ScrapHasTagPages(item_pageSouceSplit);
        //                        Domain.Socioboard.Domain.Boardfbfeeds fbfeed = new Domain.Socioboard.Domain.Boardfbfeeds();
        //                        fbfeed.Id = Guid.NewGuid();
        //                        fbfeed.Isvisible = true;
        //                        fbfeed.Message = listContent["Message"];
        //                        fbfeed.Image = listContent["PostImage"];
        //                        fbfeed.Description = listContent["Title"];
        //                        string[] splitdate = System.Text.RegularExpressions.Regex.Split(listContent["Time"], "at");
        //                        string d = splitdate[0].Trim();
        //                        string t = splitdate[1].Trim();
        //                        fbfeed.Createddate = Convert.ToDateTime(d + " " + t);
        //                        fbfeed.Feedid = listContent["PostId"];
        //                        fbfeed.Type = listContent["Type"];
        //                        fbfeed.Type = listContent["Link"];
        //                        fbfeed.Fbpageprofileid = BoardfbPageId;
        //                        if (!boardrepo.checkFacebookFeedExists(fbfeed.Feedid, BoardfbPageId))
        //                        {
        //                            boardrepo.addBoardFbPageFeed(fbfeed);
        //                        }
        //                        // Please Write Code get Dictionary data 

        //                        //

        //                    }
        //                    catch { };



        //                }

        //            }
        //            catch (Exception ex)
        //            { //GlobusLogHelper.log.Error(ex.StackTrace); 
        //            }
        //        }
        //    }
        //    catch
        //    { }





        //}



        //public Dictionary<string, string> ScrapHasTagPages(string Value)
        //{
        //    string redirectionHref = string.Empty;
        //    string title = string.Empty;
        //    List<string[]> Likedata = new List<string[]>();
        //    Dictionary<string, string> HasTagData = new Dictionary<string, string>();
        //    //  foreach (var Value in Likepages)
        //    {
        //        try
        //        {

        //            redirectionHref = Utils.getBetween(Value, "href=\"", "\"");
        //            string profileUrl = redirectionHref;//1
        //            if (redirectionHref.Contains("https://www.facebook.com"))
        //            {

        //                string[] Arr_Title = System.Text.RegularExpressions.Regex.Split(Value, "<span class=\"fwb fcg\"");
        //                foreach (var valuetitle in Arr_Title)
        //                {
        //                    try
        //                    {


        //                        // title = Utils.getBetween(valuetitle, "<a", "/a>");
        //                        title = Utils.getBetween(valuetitle, "\">", "/a>");
        //                        if (!title.Equals(string.Empty))
        //                        {
        //                            title = Utils.getBetween(title, "\">", "<");
        //                            if (!string.IsNullOrEmpty(title))
        //                            {
        //                                break;
        //                            }

        //                        }
        //                    }
        //                    catch (Exception)
        //                    {

        //                    }
        //                }
        //                string profileName = title;//2
        //                string Message = Utils.getBetween(Value, "<p>", "<").Replace("&#064;", "@").Replace("&amp;", "&").Replace("u0025", "%");//7

        //                string[] timeDetails = Regex.Split(Value, "<abbr");
        //                string postedTime = string.Empty;
        //                try
        //                {
        //                    postedTime = Utils.getBetween(timeDetails[1], "=\"", "\"");
        //                }
        //                catch { };
        //                string postid = string.Empty;

        //                try
        //                {
        //                    postid = Utils.getBetween(timeDetails[0], "fbid=", "&amp;");
        //                    if (postid == "")
        //                    {
        //                        postid = Utils.getBetween(timeDetails[0], "/posts/", "\" target=");
        //                    }
        //                }
        //                catch
        //                {
        //                }

        //                string[] DetailedInfo = System.Text.RegularExpressions.Regex.Split(Value, "<div class=\"_6m7\">");
        //                string detail = string.Empty;
        //                try
        //                {
        //                    detail = "-" + DetailedInfo[1];//8
        //                    detail = Utils.getBetween(detail, "-", "</div>").Replace("&amp;", "&").Replace("u0025", "%");
        //                    if (detail.Contains("<a "))
        //                    {
        //                        string GetVisitUrl = Utils.getBetween(detail, "\">", "</a>");
        //                        detail = Utils.getBetween("$$$####" + detail, "$$$####", "<a href=") + "-" + GetVisitUrl;
        //                    }
        //                }
        //                catch
        //                { };

        //                string[] ArrDetail = System.Text.RegularExpressions.Regex.Split(Value, "<div class=\"mbs _6m6\">");
        //                string Titles = string.Empty;
        //                // string Url = Utils.getBetween(ArrDetail[0], "", "");
        //                try
        //                {
        //                    Titles = Utils.getBetween(ArrDetail[1], ">", "</a>").Replace("&#064;", "@").Replace("&amp;", "&").Replace("u0025", "%");//6
        //                    if (Titles.Contains("Sachin Tendulkar"))
        //                    {

        //                    }
        //                }
        //                catch { };
        //                string SiteRedirectionUrl = string.Empty;
        //                try
        //                {
        //                    SiteRedirectionUrl = Utils.getBetween(ArrDetail[1], "LinkshimAsyncLink.swap(this, &quot;", ");");
        //                }
        //                catch { };
        //                try
        //                {
        //                    SiteRedirectionUrl = Uri.UnescapeDataString(SiteRedirectionUrl).Replace("\\u0025", "%").Replace("\\", "");//4
        //                }
        //                catch { };
        //                string websiteUrl = string.Empty;
        //                try
        //                {
        //                    websiteUrl = Utils.getBetween(SiteRedirectionUrl, "//", "/");
        //                }
        //                catch { };
        //                string redirectionImg = string.Empty;
        //                try
        //                {
        //                    string[] adImg = System.Text.RegularExpressions.Regex.Split(Value, "<img class=\"scaledImageFitWidth img\"");
        //                       redirectionImg = Utils.getBetween(adImg[1], "src=\"", "\"").Replace("&amp;", "&");
        //                }
        //                catch { };


        //                string[] profImg = System.Text.RegularExpressions.Regex.Split(Value, "<img class=\"_s0 5xib 5sq7 _rw img\"");
        //                string profileImg = string.Empty;
        //                try
        //                {
        //                    profileImg = Utils.getBetween(profImg[0], "src=\"", "\"").Replace("&amp;", "&");
        //                }
        //                catch { };
        //                HasTagData.Add("Title", title);
        //                HasTagData.Add("Time", postedTime);
        //                HasTagData.Add("Type", "link");
        //                HasTagData.Add("Message", Message);
        //                HasTagData.Add("Image", profileImg);
        //                HasTagData.Add("PostImage", redirectionImg);
        //                HasTagData.Add("PostId", postid);
        //                HasTagData.Add("Link", SiteRedirectionUrl);
        //            }
        //        }
        //        catch { };
        //    }

        //    return HasTagData;
        //}

        public static List<Domain.Socioboard.Domain.DiscoverySearch> ScraperHasTage(string Hash)
        {
            GlobusHttpHelper HttpHelper = new GlobusHttpHelper();
            string KeyWord = Hash;
            string pageSource_Home = HttpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/hashtag/" + KeyWord));
            List<string> pageSouceSplit = new List<string>();
            string[] PagesLink = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "_4-u2 mbm _5jmm _5pat _5v3q _4-u8");
            foreach (var item in PagesLink)
            {
                pageSouceSplit.Add(item);
            }
            PagesLink = PagesLink.Skip(1).ToArray();
            List<Domain.Socioboard.Domain.DiscoverySearch> discSearchList = new List<Domain.Socioboard.Domain.DiscoverySearch>();
            foreach (var item_pageSouceSplit in pageSouceSplit)
            {
                Domain.Socioboard.Domain.DiscoverySearch discSearchObj = new Domain.Socioboard.Domain.DiscoverySearch();
                try
                {
                    if (item_pageSouceSplit.Contains("<!DOCTYPE html>"))
                    {
                        continue;
                    }
                    Dictionary<string, string> listContent = ScrapHasTagPages(item_pageSouceSplit);
                    // Domain.Socioboard.Domain.Boardfbfeeds fbfeed = new Domain.Socioboard.Domain.Boardfbfeeds();
                    discSearchObj.Id = Guid.NewGuid();

                    discSearchObj.Message = listContent["Message"];
                    //discSearchObj.Image = listContent["PostImage"];
                    //discSearchObj.Description = listContent["Title"];
                    string[] splitdate = System.Text.RegularExpressions.Regex.Split(listContent["Time"], "at");
                    string d = splitdate[0].Trim();
                    string t = splitdate[1].Trim();
                    discSearchObj.CreatedTime = Convert.ToDateTime(d + " " + t);
                    discSearchObj.MessageId = listContent["PostId"];
                    //discSearchObj.Type = listContent["Type"];
                    //discSearchObj.Link = listContent["Link"];
                    discSearchObj.FromId = listContent["FromId"];
                    discSearchObj.FromName = listContent["FromName"];
                    //discSearchObj.Fbpageprofileid = BoardfbPageId;

                    discSearchList.Add(discSearchObj);

                }
                catch { };


            }
            return discSearchList;

        }
コード例 #13
0
        public static JArray getAllDataWithHashtagMongo(string hasttagname,  string BaordTwitterId)
        {

            if (hasttagname.Contains("#"))
            {
                hasttagname = hasttagname.Replace("#", "%23");
            }
            string url = "https://twitter.com/hashtag/" + hasttagname + "?src=tren";
            GlobusHttpHelper globushelper = new GlobusHttpHelper();


            JArray dataArray = new JArray();

            # region scraping data

            string Name_From = string.Empty;
            string Id_From = string.Empty;
            string Create_edat = string.Empty;
            string Imageurl = string.Empty;
            string Text = string.Empty;
            string Retweetcount = string.Empty;
            string Favoritedcount = string.Empty;
            string FeedId = string.Empty;
            string FeedUrl = string.Empty;
            string profileImage = string.Empty;
            // string Name_From = string.Empty;

            int exit = 0;
            string page = globushelper.getHtmlfromUrl(new Uri(url), "", "");

            List<string> dataList = new List<string>();

            MongoRepository boardtwtfeedsrepo = new MongoRepository("MongoBoardTwtFeeds");





            //if (page.Contains("class=\"tweet original-tweet js-stream-tweet js-actionable-tweet js-profile-popup-actionable js-original-tweet")) //js-stream-item stream-item stream-item expanding-stream-item
            if (page.Contains("js-stream-item stream-item stream-item expanding-stream-item"))
            {

                string[] listPage = Regex.Split(page, "js-stream-item stream-item stream-item expanding-stream-item");

                List<string> listPageList = listPage.ToList();
                listPageList.RemoveAt(0);


                foreach (string item in listPageList)
                {

                    #region commented

                    /*
                    if (item.Contains("!DOCTYPE html"))
                    {

                        continue;
                    }


                    try
                    {
                        string[] Name_FromList = Regex.Split(item, "fullname js-action-profile-name show-popup-with-id");

                        Name_From = Utils.getBetween(Name_FromList[1], ">", "<");
                    }
                    catch { };


                    try
                    {
                        string[] Name_FromList = Regex.Split(item, "account-group js-account-group js-action-profile js-user-profile-link js-nav");

                        Id_From = Utils.getBetween(Name_FromList[1], "data-user-id=\"", "\"");
                    }
                    catch { };




                    try
                    {
                        //string[] Name_FromList = Regex.Split(item, "_timestamp js-short-timestamp js-relative-timestamp");  //tweet-timestamp js-permalink js-nav js-tooltip
                        //  Create_edat = Utils.getBetween(Name_FromList[1], ">", "<");
                        string[] Name_FromList = Regex.Split(item, "tweet-timestamp js-permalink js-nav js-tooltip");

                        Create_edat = Utils.getBetween(Name_FromList[1], "title=\"", "\"");
                    }
                    catch { };



                    try
                    {
                        //data-src="

                        // string[] Name_FromList = Regex.Split(item, "class=\" is-preview\"");

                        Imageurl = Utils.getBetween(item, "data-src=\"", "\"");
                        if (!string.IsNullOrEmpty(Imageurl))
                        {
                            Imageurl = "https://twitter.com" + Imageurl;
                        }
                        else
                        {
                            Imageurl = Utils.getBetween(item, "data-img-src=\"", "\"");

                        }

                    }
                    catch { };

                    try
                    {
                        string[] Name_FromList = Regex.Split(item, "class=\"TweetTextSize  js-tweet-text tweet-text\"");



                        Text = Utils.getBetween(Name_FromList[1], ">", "</p>");
                        int count = 0;

                        if (Text.Contains("<a "))
                        {
                            try
                            {
                                count = Regex.Split(Text, "<a").Count();
                            }
                            catch { };
                            for (int i = 0; i < count; i++)
                            {
                                try
                                {
                                    if (Text.Contains("<a "))
                                    {
                                        string ReplaceInBetween = Utils.getBetween(Text, "<a ", "</a>");
                                        ReplaceInBetween = "<a " + ReplaceInBetween + "</a>";
                                        Text = Text.Replace(ReplaceInBetween, "");
                                    }
                                }
                                catch { };
                            }
                        }

                        if (Text.Contains("<img"))
                        {

                            try
                            {
                                count = Regex.Split(Text, "<img").Count();
                            }
                            catch { };
                            for (int i = 0; i < count; i++)
                            {
                                try
                                {
                                    if (Text.Contains("<img "))
                                    {
                                        string ReplaceInBetween = Utils.getBetween(Text, "<img ", ">");
                                        ReplaceInBetween = "<img " + ReplaceInBetween + ">";
                                        Text = Text.Replace(ReplaceInBetween, "");
                                    }
                                }
                                catch { };
                            }
                        }





                        if (Text.Contains("<a "))
                        {
                            string ReplaceInBetween = Utils.getBetween(Text, "<a ", "</a>");
                            ReplaceInBetween = "<a " + ReplaceInBetween + "</a>";
                            Text = Text.Replace(ReplaceInBetween, "").Replace("&", "").Replace("#", "").Replace(";", "");
                        }
                        Text = Text.Replace("&", "").Replace("#", "").Replace(";", "");


                    }
                    catch { };

                    try
                    {
                        //Retweet
                        string[] Name_FromListFirst = Regex.Split(item, ">Retweet<");

                        string[] Name_FromList = Regex.Split(Name_FromListFirst[1], "class=\"ProfileTweet-actionCountForPresentation\"");
                        Retweetcount = Utils.getBetween(Name_FromList[1], ">", "<");
                    }
                    catch { };


                    try
                    {
                        //>Favorite<
                        string[] Name_FromListFirst = Regex.Split(item, ">Favorite<");
                        string[] Name_FromList = Regex.Split(Name_FromListFirst[1], "class=\"ProfileTweet-actionCountForPresentation\"");
                        Favoritedcount = Utils.getBetween(Name_FromList[1], ">", "<");
                    }
                    catch { };


                    try
                    {
                        //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                        FeedId = Utils.getBetween(item, "data-tweet-id=\"", "\"");
                    }
                    catch { };


                    try
                    {
                        //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                        FeedUrl = Utils.getBetween(item, "data-permalink-path=\"", "\"");
                        FeedUrl = "https://twitter.com" + FeedUrl;
                    }
                    catch { };


                    */

                    #endregion

                    #region NewCode

                    Name_From = "";
                    Id_From = "";
                    Create_edat = "";
                    Imageurl = "";
                    Text = string.Empty;
                    Retweetcount = "";
                    Favoritedcount = "";
                    FeedId = "";
                    FeedUrl = "";
                    // string Name_From = string.Empty;
                    profileImage = "";





                    if (item.Contains("!DOCTYPE html"))
                    {

                        continue;
                    }


                    try
                    {
                        string[] Name_FromList = Regex.Split(item, "fullname js-action-profile-name show-popup-with-id");

                        Name_From = Utils.getBetween(Name_FromList[1], ">", "<");
                    }
                    catch { };


                    try
                    {
                        string[] Name_FromList = Regex.Split(item, "account-group js-account-group js-action-profile js-user-profile-link js-nav");

                        Id_From = Utils.getBetween(Name_FromList[1], "data-user-id=\"", "\"");
                    }
                    catch { };




                    try
                    {
                        //string[] Name_FromList = Regex.Split(item, "_timestamp js-short-timestamp js-relative-timestamp");  //tweet-timestamp js-permalink js-nav js-tooltip
                        //  Create_edat = Utils.getBetween(Name_FromList[1], ">", "<");
                        string[] Name_FromList = Regex.Split(item, "tweet-timestamp js-permalink js-nav js-tooltip");

                        Create_edat = Utils.getBetween(Name_FromList[1], "title=\"", "\"");
                    }
                    catch { };



                    try
                    {
                        //data-src="

                        // string[] Name_FromList = Regex.Split(item, "class=\" is-preview\"");

                        Imageurl = Utils.getBetween(item, "data-src=\"", "\"");
                        if (!string.IsNullOrEmpty(Imageurl))
                        {
                            Imageurl = "https://twitter.com" + Imageurl;
                        }
                        else
                        {
                            Imageurl = Utils.getBetween(item, "data-img-src=\"", "\"");

                        }

                    }
                    catch { };

                    try
                    {
                        string[] Name_FromList = Regex.Split(item, "class=\"TweetTextSize  js-tweet-text tweet-text\"");



                        Text = Utils.getBetween(Name_FromList[1], ">", "</p>");
                        int count = 0;

                        if (Text.Contains("<a "))
                        {
                            try
                            {
                                count = Regex.Split(Text, "<a").Count();
                            }
                            catch { };
                            for (int i = 0; i < count; i++)
                            {
                                try
                                {
                                    if (Text.Contains("<a "))
                                    {
                                        string ReplaceInBetween = Utils.getBetween(Text, "<a ", "</a>");
                                        ReplaceInBetween = "<a " + ReplaceInBetween + "</a>";
                                        Text = Text.Replace(ReplaceInBetween, "");
                                    }
                                }
                                catch { };
                            }
                        }

                        if (Text.Contains("<img"))
                        {

                            try
                            {
                                count = Regex.Split(Text, "<img").Count();
                            }
                            catch { };
                            for (int i = 0; i < count; i++)
                            {
                                try
                                {
                                    if (Text.Contains("<img "))
                                    {
                                        string ReplaceInBetween = Utils.getBetween(Text, "<img ", ">");
                                        ReplaceInBetween = "<img " + ReplaceInBetween + ">";
                                        Text = Text.Replace(ReplaceInBetween, "");
                                    }
                                }
                                catch { };
                            }
                        }





                        if (Text.Contains("<a "))
                        {
                            string ReplaceInBetween = Utils.getBetween(Text, "<a ", "</a>");
                            ReplaceInBetween = "<a " + ReplaceInBetween + "</a>";
                            Text = Text.Replace(ReplaceInBetween, "").Replace("&", "").Replace("#", "").Replace(";", "");
                        }
                        Text = Text.Replace("&", "").Replace("#", "").Replace(";", "");


                    }
                    catch { };

                    try
                    {
                        //Retweet
                        string[] Name_FromListFirst = Regex.Split(item, ">Retweet<");

                        string[] Name_FromList = Regex.Split(Name_FromListFirst[1], "class=\"ProfileTweet-actionCountForPresentation\"");
                        Retweetcount = Utils.getBetween(Name_FromList[1], ">", "<");
                    }
                    catch { };


                    try
                    {
                        //>Favorite<
                        string[] Name_FromListFirst = Regex.Split(item, ">Favorite<");
                        string[] Name_FromList = Regex.Split(Name_FromListFirst[1], "class=\"ProfileTweet-actionCountForPresentation\"");
                        Favoritedcount = Utils.getBetween(Name_FromList[1], ">", "<");
                    }
                    catch { };


                    try
                    {
                        //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                        FeedId = Utils.getBetween(item, "data-tweet-id=\"", "\"");
                    }
                    catch { };


                    try
                    {
                        //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                        FeedUrl = Utils.getBetween(item, "data-permalink-path=\"", "\"");
                        FeedUrl = "https://twitter.com" + FeedUrl;
                    }
                    catch { };


                    try
                    {
                        //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                        FeedUrl = Utils.getBetween(item, "data-permalink-path=\"", "\"");
                        FeedUrl = "https://twitter.com" + FeedUrl;
                    }
                    catch { };


                    try
                    {
                        //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                        profileImage = Utils.getBetween(item, "src=\"", "\"");
                        // profileImage = "https://twitter.com" + FeedUrl;
                    }
                    catch { }; Name_From = "";
                    Id_From = "";
                    Create_edat = "";
                    Imageurl = "";
                    Text = string.Empty;
                    Retweetcount = "";
                    Favoritedcount = "";
                    FeedId = "";
                    FeedUrl = "";
                    // string Name_From = string.Empty;
                    profileImage = "";





                    if (item.Contains("!DOCTYPE html"))
                    {

                        continue;
                    }


                    try
                    {
                        string[] Name_FromList = Regex.Split(item, "fullname js-action-profile-name show-popup-with-id");

                        Name_From = Utils.getBetween(Name_FromList[1], ">", "<");
                    }
                    catch { };


                    try
                    {
                        string[] Name_FromList = Regex.Split(item, "account-group js-account-group js-action-profile js-user-profile-link js-nav");

                        Id_From = Utils.getBetween(Name_FromList[1], "data-user-id=\"", "\"");
                    }
                    catch { };




                    try
                    {
                        //string[] Name_FromList = Regex.Split(item, "_timestamp js-short-timestamp js-relative-timestamp");  //tweet-timestamp js-permalink js-nav js-tooltip
                        //  Create_edat = Utils.getBetween(Name_FromList[1], ">", "<");
                        string[] Name_FromList = Regex.Split(item, "tweet-timestamp js-permalink js-nav js-tooltip");

                        Create_edat = Utils.getBetween(Name_FromList[1], "title=\"", "\"");
                    }
                    catch { };



                    try
                    {
                        //data-src="

                        // string[] Name_FromList = Regex.Split(item, "class=\" is-preview\"");

                        Imageurl = Utils.getBetween(item, "data-src=\"", "\"");
                        if (!string.IsNullOrEmpty(Imageurl))
                        {
                            Imageurl = "https://twitter.com" + Imageurl;
                        }
                        else
                        {
                            Imageurl = Utils.getBetween(item, "data-img-src=\"", "\"");

                        }

                    }
                    catch { };

                    try
                    {
                        string[] Name_FromList = Regex.Split(item, "class=\"TweetTextSize  js-tweet-text tweet-text\"");



                        Text = Utils.getBetween(Name_FromList[1], ">", "</p>");
                        int count = 0;

                        if (Text.Contains("<a "))
                        {
                            try
                            {
                                count = Regex.Split(Text, "<a").Count();
                            }
                            catch { };
                            for (int i = 0; i < count; i++)
                            {
                                try
                                {
                                    if (Text.Contains("<a "))
                                    {
                                        string ReplaceInBetween = Utils.getBetween(Text, "<a ", "</a>");
                                        ReplaceInBetween = "<a " + ReplaceInBetween + "</a>";
                                        Text = Text.Replace(ReplaceInBetween, "");
                                    }
                                }
                                catch { };
                            }
                        }

                        if (Text.Contains("<img"))
                        {

                            try
                            {
                                count = Regex.Split(Text, "<img").Count();
                            }
                            catch { };
                            for (int i = 0; i < count; i++)
                            {
                                try
                                {
                                    if (Text.Contains("<img "))
                                    {
                                        string ReplaceInBetween = Utils.getBetween(Text, "<img ", ">");
                                        ReplaceInBetween = "<img " + ReplaceInBetween + ">";
                                        Text = Text.Replace(ReplaceInBetween, "");
                                    }
                                }
                                catch { };
                            }
                        }





                        if (Text.Contains("<a "))
                        {
                            string ReplaceInBetween = Utils.getBetween(Text, "<a ", "</a>");
                            ReplaceInBetween = "<a " + ReplaceInBetween + "</a>";
                            Text = Text.Replace(ReplaceInBetween, "").Replace("&", "").Replace("#", "").Replace(";", "");
                        }
                        Text = Text.Replace("&", "").Replace("#", "").Replace(";", "");


                    }
                    catch { };

                    try
                    {
                        //Retweet
                        string[] Name_FromListFirst = Regex.Split(item, ">Retweet<");

                        string[] Name_FromList = Regex.Split(Name_FromListFirst[1], "class=\"ProfileTweet-actionCountForPresentation\"");
                        Retweetcount = Utils.getBetween(Name_FromList[1], ">", "<");
                    }
                    catch { };


                    try
                    {
                        //>Favorite<
                        string[] Name_FromListFirst = Regex.Split(item, ">Favorite<");
                        string[] Name_FromList = Regex.Split(Name_FromListFirst[1], "class=\"ProfileTweet-actionCountForPresentation\"");
                        Favoritedcount = Utils.getBetween(Name_FromList[1], ">", "<");
                    }
                    catch { };


                    try
                    {
                        //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                        FeedId = Utils.getBetween(item, "data-tweet-id=\"", "\"");
                    }
                    catch { };


                    try
                    {
                        //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                        FeedUrl = Utils.getBetween(item, "data-permalink-path=\"", "\"");
                        FeedUrl = "https://twitter.com" + FeedUrl;
                    }
                    catch { };


                    try
                    {
                        //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                        FeedUrl = Utils.getBetween(item, "data-permalink-path=\"", "\"");
                        FeedUrl = "https://twitter.com" + FeedUrl;
                    }
                    catch { };


                    try
                    {
                        //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                        profileImage = Utils.getBetween(item, "src=\"", "\"");
                        // profileImage = "https://twitter.com" + FeedUrl;
                    }
                    catch { };


                    #endregion


                    string data = "Name_From : " + Name_From + "                 +                 " + "Id_From : " + Id_From + "                 +                 " + "Create_edat : " + Create_edat + "                 +                 " + "Imageurl : " + Imageurl + "                 +                 " + "Text : " + Text + "                 +                 " + "Retweetcount : " + Retweetcount + "                 +                 " + "Favoritedcount : " + Favoritedcount + "                 +                 " + "FeedId : " + FeedId + "                 +                 " + "FeedUrl : " + FeedUrl;
                    dataList.Add(data);


                    JObject feedobj = new JObject();
                    try
                    {

                        string[] datearry = Create_edat.Split(' ');
                        Create_edat = DateTime.Parse(datearry[3] + " " + datearry[4] + " " + datearry[5] + " " + datearry[0] + " " + datearry[1]).ToString();
                    
                    }
                    catch { }
                    feedobj.Add("Name_From", Name_From);
                    feedobj.Add("Id_From", Id_From);
                    feedobj.Add("Create_edat", Create_edat);
                    feedobj.Add("Imageurl", Imageurl);
                    feedobj.Add("Text", Text);
                    feedobj.Add("Retweetcount", Retweetcount);
                    feedobj.Add("Favoritedcount", Favoritedcount);
                    feedobj.Add("FeedId", FeedId);
                    feedobj.Add("FeedUrl", FeedUrl);
                    feedobj.Add("profileImage", profileImage);
                    dataArray.Add(feedobj);



                    MongoBoardTwtFeeds twitterfeed = new MongoBoardTwtFeeds();
                    twitterfeed.Id = ObjectId.GenerateNewId();
                    twitterfeed.FromName = feedobj["Name_From"].ToString();
                    twitterfeed.FromId = feedobj["Id_From"].ToString();
                    twitterfeed.Imageurl = feedobj["Imageurl"].ToString();
                    twitterfeed.FromPicUrl = feedobj["profileImage"].ToString();  //please Add ProfileImageField in MongoBoardTwtFeeds class
                    twitterfeed.Text = feedobj["Text"].ToString();
                    twitterfeed.Feedid = feedobj["FeedId"].ToString();
                    twitterfeed.Twitterprofileid = BaordTwitterId;
                    twitterfeed.Isvisible = true;
                    try
                    {
                        twitterfeed.Createdat = DateTime.Parse(feedobj["Create_edat"].ToString()).ToString("yyyy/MM/dd HH:mm:ss");
                    }
                    catch { }
                    try
                    {
                        twitterfeed.Retweetcount = Convert.ToInt32(feedobj["Retweetcount"].ToString());
                    }
                    catch { }
                    try
                    {
                        twitterfeed.Favoritedcount = Convert.ToInt32(feedobj["Favoritedcount"].ToString());
                    }
                    catch { }
                    
                        //twtFeedsList.Add(twitterfeed);
                    boardtwtfeedsrepo.Add<MongoBoardTwtFeeds>(twitterfeed);
                    exit++;

                    // "https://twitter.com/hashtag/" + hasttagname + "?src=tren"

                }


            }


            try
            {

                string paginationdataurl = Utils.getBetween(page, "data-max-position=\"", "\"");

                string paginationUrl = "https://twitter.com/i/search/timeline?q=" + hasttagname + "&src=typd&vertical=default&include_available_features=1&include_entities=1&max_position=" + paginationdataurl;



                while (true)
                {
                    exit++;
                    if (exit == 500) 
                    {
                        return dataArray;
                    }
                    page = globushelper.getHtmlfromUrl(new Uri(paginationUrl), "", "");


                    if (!page.Contains("has_more_items"))
                    {

                        return dataArray;

                    }




                    try
                    {



                        //js-stream-item stream-item stream-item expanding-stream-item


                        if (page.Contains("js-stream-item stream-item stream-item expanding-stream-item"))
                        {

                            string[] listPage = Regex.Split(page, "js-stream-item stream-item stream-item expanding-stream-item");

                            List<string> listPageList = listPage.ToList();
                            listPageList.RemoveAt(0);


                            foreach (string item in listPageList)
                            {

                                #region Commented
                                /*

                                if (item.Contains("!DOCTYPE html"))
                                {

                                    continue;
                                }


                                try
                                {
                                    // string[] Name_FromList = Regex.Split(item, "fullname js-action-profile-name show-popup-with-id");

                                    Name_From = Utils.getBetween(item, "data-name=\\\"", "\\\"");
                                }
                                catch { };


                                try
                                {
                                    string[] Name_FromList = Regex.Split(item, "account-group js-account-group js-action-profile js-user-profile-link js-nav");

                                    Id_From = Utils.getBetween(item, "data-user-id=\\\"", "\\\"");
                                }
                                catch { };




                                try
                                {
                                    // string[] Name_FromList = Regex.Split(item, "_timestamp js-short-timestamp js-relative-timestamp");

                                    Create_edat = Utils.getBetween(item, "tooltip\\\" title=\\\"", "\\\"");
                                }
                                catch { };



                                try
                                {
                                    // string[] Name_FromList = Regex.Split(item, "class=\" is-preview\"");

                                    //    Imageurl = Utils.getBetween(item, "src=\\\"", "\\\""); data-img-src=\"

                                    Imageurl = Utils.getBetween(item, "data-img-src=\\\"", "\\\"");
                                    Imageurl = Imageurl.Replace("\\", "");

                                }
                                catch { };




                                try
                                {
                                    string[] Name_FromList = Regex.Split(item, "js-tweet-text tweet-text");

                                    Text = Utils.getBetween(Name_FromList[1], "data-aria-label-part=\\\"0\\\"\\", "\\");

                                    if (Text.Contains("u003e"))
                                    {
                                        Text = Text.Replace("u003e", "");

                                    }

                                    /*
                                    if (Text.Contains("<a "))
                                    {
                                        string ReplaceInBetween = Utils.getBetween(Text, "<a ", "</a>");
                                        ReplaceInBetween = "<a " + ReplaceInBetween + "</a>";
                                        Text = Text.Replace(ReplaceInBetween, "");
                                    }

                                    if (Text.Contains("<a "))
                                    {
                                        string ReplaceInBetween = Utils.getBetween(Text, "<a ", "</a>");
                                        ReplaceInBetween = "<a " + ReplaceInBetween + "</a>";
                                        Text = Text.Replace(ReplaceInBetween, "");
                                    }
                                     


                                }
                                catch { };

                                try
                                {
                                    //Retweet
                                    string[] Name_FromListFirst = Regex.Split(item, "retweet");

                                    // string[] Name_FromList = Regex.Split(Name_FromListFirst[1], "class=\"ProfileTweet-actionCountForPresentation\"");
                                    Retweetcount = Utils.getBetween(Name_FromListFirst[1], "data-tweet-stat-count=\\\"", "\\\"");
                                }
                                catch { };


                                try
                                {
                                    //>Favorite<
                                    string[] Name_FromListFirst = Regex.Split(item, "favorite");
                                    // string[] Name_FromList = Regex.Split(Name_FromListFirst[1], "class=\"ProfileTweet-actionCountForPresentation\"");
                                    Favoritedcount = Utils.getBetween(Name_FromListFirst[1], "data-tweet-stat-count=\\\"", "\\\"");
                                }
                                catch { };


                                try
                                {
                                    //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                                    FeedId = Utils.getBetween(item, "ndata-tweet-id=\\\"", "\\\"");
                                }
                                catch { };

                                try
                                {
                                    //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                                    FeedUrl = Utils.getBetween(item, "ndata-permalink-path=\\\"", "\"");
                                    FeedUrl = FeedUrl.Replace("\\", "");

                                    FeedUrl = "https://twitter.com" + FeedUrl;
                                }
                                catch { };
                                */

                                #endregion



                                 #region NewCode

                    
                                Name_From = "";
                                Id_From = "";
                                Create_edat = "";
                                Imageurl = "";
                                Text = string.Empty;
                                Retweetcount = "";
                                Favoritedcount = "";
                                FeedId = "";
                                FeedUrl = "";
                                // string Name_From = string.Empty;
                                profileImage = "";







                                if (item.Contains("!DOCTYPE html"))
                                {

                                    continue;
                                }





                                try
                                {
                                   // string[] Name_FromList = Regex.Split(item, "fullname js-action-profile-name show-popup-with-id");

                                    Name_From = Utils.getBetween(item, "data-name=\\\"", "\\\"");

                                    if (Name_From.Contains("&apm;"))
                                    {
                                        Name_From = Name_From.Replace("&amp;", " ");
 
                                    }
                                }
                                catch { };


                                try
                                {
                                    string[] Name_FromList = Regex.Split(item, "account-group js-account-group js-action-profile js-user-profile-link js-nav");

                                    Id_From = Utils.getBetween(item, "data-user-id=\\\"", "\\\"");
                                }
                                catch { };




                                try
                                {
                                   // string[] Name_FromList = Regex.Split(item, "_timestamp js-short-timestamp js-relative-timestamp");

                                    Create_edat = Utils.getBetween(item , "tooltip\\\" title=\\\"", "\\\"");
                                }
                                catch { };



                                try
                                {
                                   // string[] Name_FromList = Regex.Split(item, "class=\" is-preview\"");

                                //    Imageurl = Utils.getBetween(item, "src=\\\"", "\\\""); data-img-src=\"

                                    Imageurl = Utils.getBetween(item, "data-img-src=\\\"", "\\\""); 
                                    Imageurl = Imageurl.Replace("\\", "");

                                }
                                catch { };




                                try
                                {
                                    // string[] Name_FromList = Regex.Split(item, "class=\" is-preview\"");

                                    //    Imageurl = Utils.getBetween(item, "src=\\\"", "\\\""); data-img-src=\"

                                    profileImage = Utils.getBetween(item, "src=\\\"", "\\\"");
                                    profileImage = profileImage.Replace("\\", "");

                                }
                                catch { };





                                try
                                {
                                    string[] Name_FromList = Regex.Split(item, "js-tweet-text tweet-text");

                                    string betweenText = Utils.getBetween(Name_FromList[1], "data-aria-label-part=\\\"0\\\"\\", "twitter-timeline-link");

                                    if (string.IsNullOrEmpty(betweenText))
                                    {
                                        betweenText = Utils.getBetween(Name_FromList[1], "data-aria-label-part=\\\"0\\\"\\", "tweet-details");

                                    }


                                     Text = Utils.getBetween(Name_FromList[1], "data-aria-label-part=\\\"0\\\"\\", "\\");

                                     Text = "";

                                      //  Text =  Text + " " +  Utils.getBetween(Name_FromList[1], ";", "\\");
                                  
                                    //string[] stringTextSplit = Regex.Split(Name_FromList[1],"#10;");
                                    //List<string> stringTextSplitList = stringTextSplit.ToList();
                                    //stringTextSplitList.RemoveAt(0);
                                    //foreach (string item1 in stringTextSplitList)
                                    //{
                                    //    Text += Utils.getBetween(item1, "", "\\");
                                    //}



                                     string[] stringTextSplit = Regex.Split(betweenText,"u003e");
                                    List<string> stringTextSplitList = stringTextSplit.ToList();
                                    stringTextSplitList.RemoveAt(0);
                                    foreach (string item1 in stringTextSplitList)
                                    {
                                        Text += Utils.getBetween(item1, "", "\\");
                                    }





                                    try
                                    {
                                        Text = Text.Replace("u003e", "").Replace("#39;", "").Replace("amp;", "").Replace(";", "");




                                    }
                                    catch { };

                                    /*
                                    if (Text.Contains("<a "))
                                    {
                                        string ReplaceInBetween = Utils.getBetween(Text, "<a ", "</a>");
                                        ReplaceInBetween = "<a " + ReplaceInBetween + "</a>";
                                        Text = Text.Replace(ReplaceInBetween, "");
                                    }

                                    if (Text.Contains("<a "))
                                    {
                                        string ReplaceInBetween = Utils.getBetween(Text, "<a ", "</a>");
                                        ReplaceInBetween = "<a " + ReplaceInBetween + "</a>";
                                        Text = Text.Replace(ReplaceInBetween, "");
                                    }
                                     */


                                }
                                catch { };

                                try
                                {
                                    //Retweet
                                    string[] Name_FromListFirst = Regex.Split(item, "retweet");

                                   // string[] Name_FromList = Regex.Split(Name_FromListFirst[1], "class=\"ProfileTweet-actionCountForPresentation\"");
                                    Retweetcount = Utils.getBetween(Name_FromListFirst[1], "data-tweet-stat-count=\\\"", "\\\"");
                                }
                                catch { };


                                try
                                {
                                    //>Favorite<
                                    string[] Name_FromListFirst = Regex.Split(item, "favorite");
                                   // string[] Name_FromList = Regex.Split(Name_FromListFirst[1], "class=\"ProfileTweet-actionCountForPresentation\"");
                                    Favoritedcount = Utils.getBetween(Name_FromListFirst[1], "data-tweet-stat-count=\\\"", "\\\"");
                                }
                                catch { };


                                try
                                {
                                    //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                                    FeedId = Utils.getBetween(item, "ndata-tweet-id=\\\"", "\\\"");
                                    FeedId = Utils.getBetween(item, "=\\\"", "\\\"");
                                }
                                catch { };

                                try
                                {
                                    //  string[] Name_FromList = Regex.Split(item, "class=\"ProfileTweet-actionCountForPresentation\"");
                                    FeedUrl = Utils.getBetween(item, "ndata-permalink-path=\\\"", "\"");
                                    FeedUrl = FeedUrl.Replace("\\", "");

                                    FeedUrl = "https://twitter.com" + FeedUrl;
                                }
                                catch { };




    #endregion


                                string data = "Name_From : " + Name_From + "                 +                 " + "Id_From : " + Id_From + "                 +                 " + "Create_edat : " + Create_edat + "                 +                 " + "Imageurl : " + Imageurl + "                 +                 " + "Text : " + Text + "                 +                 " + "Retweetcount : " + Retweetcount + "                 +                 " + "Favoritedcount : " + Favoritedcount + "                 +                 " + "FeedId : " + FeedId + "                 +                 " + "FeedUrl : " + FeedUrl;
                                dataList.Add(data);
                                JObject feedobj = new JObject();
                                try
                                {
                                    string[] datearry = Create_edat.Split(' ');
                                    Create_edat = DateTime.Parse(datearry[3] + " " + datearry[4] + " " + datearry[5] + " " + datearry[0] + " " + datearry[1]).ToString();
                                }
                                catch { }
                                feedobj.Add("Name_From", Name_From);
                                feedobj.Add("Id_From", Id_From);
                                feedobj.Add("Create_edat", Create_edat);
                                feedobj.Add("Imageurl", Imageurl);
                                feedobj.Add("profileImage", profileImage);
                                feedobj.Add("Text", Text);
                                feedobj.Add("Retweetcount", Retweetcount);
                                feedobj.Add("Favoritedcount", Favoritedcount);
                                feedobj.Add("FeedId", FeedId);
                                feedobj.Add("FeedUrl", FeedUrl);
                                dataArray.Add(feedobj);



                                MongoBoardTwtFeeds twitterfeed = new MongoBoardTwtFeeds();
                                twitterfeed.Id = ObjectId.GenerateNewId();
                                twitterfeed.FromName = feedobj["Name_From"].ToString();
                                twitterfeed.FromId = feedobj["Id_From"].ToString();
                                twitterfeed.Imageurl = feedobj["Imageurl"].ToString();
                                twitterfeed.FromPicUrl = feedobj["profileImage"].ToString();  //please Add ProfileImageField in MongoBoardTwtFeeds class
                                twitterfeed.Text = feedobj["Text"].ToString();
                                twitterfeed.Feedid = feedobj["FeedId"].ToString();
                                twitterfeed.Twitterprofileid = BaordTwitterId;
                                twitterfeed.Isvisible = true;
                                try
                                {
                                    twitterfeed.Createdat = DateTime.Parse(feedobj["Create_edat"].ToString()).ToString("yyyy/MM/dd HH:mm:ss");
                                }
                                catch { }
                                try
                                {
                                    twitterfeed.Retweetcount = Convert.ToInt32(feedobj["Retweetcount"].ToString());
                                }
                                catch { }
                                try
                                {
                                    twitterfeed.Favoritedcount = Convert.ToInt32(feedobj["Favoritedcount"].ToString());
                                }
                                catch { }

                                boardtwtfeedsrepo.Add<MongoBoardTwtFeeds>(twitterfeed);

                                exit++;
                                // "https://twitter.com/hashtag/" + hasttagname + "?src=tren"

                            }

                        }
                        try
                        {

                            paginationdataurl = Utils.getBetween(page, "min_position\":\"", "\"");

                            paginationUrl = "https://twitter.com/i/search/timeline?q=" + hasttagname + "&src=typd&vertical=default&include_available_features=1&include_entities=1&max_position=" + paginationdataurl;

                        }
                        catch { }
                    }
                    catch { }

                }


            }
            catch { }




            #endregion




            return dataArray;



        }
コード例 #14
0
        //public void ScraperHasTage(ref FacebookUser fbUser, string Hash, Guid BoardfbPageId)
        //{


        //    GlobusHttpHelper HttpHelper = fbUser.globusHttpHelper;
        //    string KeyWord = Hash;
        //    string pageSource_Home = HttpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/hashtag/" + KeyWord));
        //    List<string> pageSouceSplit = new List<string>();
        //    string[] trendingArr = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "li data-topicid=");
        //    string[] PagesLink = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "uiLikePageButton");
        //    foreach (var item in PagesLink)
        //    {
        //        pageSouceSplit.Add(item);
        //    }
        //    PagesLink = PagesLink.Skip(1).ToArray();

        //    foreach (var item_pageSouceSplit in pageSouceSplit)
        //    {
        //        try
        //        {
        //            if (item_pageSouceSplit.Contains("<!DOCTYPE html>"))
        //            {
        //                continue;
        //            }
        //            Dictionary<string, string> listContent = ScrapHasTagPages(item_pageSouceSplit);
        //            Domain.Socioboard.Domain.Boardfbfeeds fbfeed = new Domain.Socioboard.Domain.Boardfbfeeds();
        //            fbfeed.Id = Guid.NewGuid();
        //            fbfeed.Isvisible = true;
        //            fbfeed.Message = listContent["Message"];
        //            fbfeed.Image = listContent["PostImage"];
        //            fbfeed.Description = listContent["Title"];
        //            string[] splitdate = System.Text.RegularExpressions.Regex.Split(listContent["Time"], "at");
        //            string d = splitdate[0].Trim();
        //            string t = splitdate[1].Trim();
        //            fbfeed.Createddate = Convert.ToDateTime(d + " " + t);
        //            fbfeed.Feedid = listContent["PostId"];
        //            fbfeed.Type = listContent["Type"];
        //            fbfeed.Type = listContent["Link"];
        //            fbfeed.Fbpageprofileid = BoardfbPageId;
        //             if (!boardrepo.checkFacebookFeedExists(fbfeed.Feedid, BoardfbPageId))
        //             {
        //                 boardrepo.addBoardFbPageFeed(fbfeed);
        //             }

        //            // Please Write Code get Dictionary data 

        //            //


        //        }
        //        catch { };



        //    }


        //    try
        //    {


        //        string ajaxpipe_token = Utils.getBetween(pageSource_Home, "\"ajaxpipe_token\":\"", "\"");
        //        string[] data_c = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "data-cursor=");
        //        string cursor = Utils.getBetween(data_c[4], "\"", "=");
        //        if (cursor.Contains("data-dedupekey"))
        //        {
        //            cursor = "-" + cursor;
        //            cursor = Utils.getBetween(cursor, "-", "\"");
        //        }
        //        string sectionid = Utils.getBetween(pageSource_Home, "section_id\\\":", ",");
        //        string userid = Utils.getBetween(pageSource_Home, "USER_ID\":\"", "\"");
        //        string feed_Id = "90842368";
        //        string pager_id = "u_ps_0_0_1n";
        //        for (int i = 2; i < 50; i++)
        //        {
        //            try
        //            {
        //                Thread.Sleep(30 * 1000);

        //                List<string> pageSouceSplitPagination = new List<string>();
        //                if (string.IsNullOrEmpty(fbUser.username))
        //                {
        //                    break;
        //                }
        //                //GlobusLogHelper.log.Info("Please wait... Searching for data from Page :" + i + "   with User Name : " + fbUser.username);


        //                string req = "https://www.facebook.com/ajax/pagelet/generic.php/LitestandMoreStoriesPagelet?ajaxpipe=1&ajaxpipe_token=" + ajaxpipe_token + "&no_script_path=1&data=%7B%22cursor%22%3A%22" + cursor + "%22%2C%22preload_next_cursor%22%3Anull%2C%22pager_config%22%3A%22%7B%5C%22edge%5C%22%3Anull%2C%5C%22source_id%5C%22%3Anull%2C%5C%22section_id%5C%22%3A" + sectionid + "%2C%5C%22pause_at%5C%22%3Anull%2C%5C%22stream_id%5C%22%3Anull%2C%5C%22section_type%5C%22%3A1%2C%5C%22sizes%5C%22%3Anull%2C%5C%22most_recent%5C%22%3Afalse%2C%5C%22unread_session%5C%22%3Afalse%2C%5C%22continue_top_news_feed%5C%22%3Afalse%2C%5C%22ranking_model%5C%22%3Anull%2C%5C%22unread_only%5C%22%3Afalse%7D%22%2C%22pager_id%22%3A%22" + pager_id + "%22%2C%22scroll_count%22%3A1%2C%22start_unread_session%22%3Afalse%2C%22start_continue_top_news_feed%22%3Afalse%2C%22feed_stream_id%22%3A" + feed_Id + "%2C%22snapshot_time%22%3Anull%7D&__user="******"&__a=1&__dyn=7nm8RW8BgCBynzpQ9UoHaEWCueyrhEK49oKiWFaaBGeqrYw8popyujhElx2ubhHximmey8szoyfwgo&__req=jsonp_2&__rev=1583304&__adt=" + i + "";      //
        //                string respReq = HttpHelper.getHtmlfromUrl(new Uri(req));

        //                respReq = respReq.Replace("\\", "").Replace("u003C", "<");
        //                string[] arrrespReq = System.Text.RegularExpressions.Regex.Split(respReq, "source_id");
        //                feed_Id = Utils.getBetween(respReq, "feed_stream_id", "snapshot_time");
        //                feed_Id = Utils.getBetween(feed_Id, "A", "u");

        //                string[] pager_id1 = System.Text.RegularExpressions.Regex.Split(respReq, "_4-u2 mbl ");
        //                pager_id = Utils.getBetween(pager_id1[2], "id=\"", "\"");
        //                data_c = System.Text.RegularExpressions.Regex.Split(respReq, "data-cursor=");
        //                if (data_c.Length < 8)
        //                {
        //                    cursor = Utils.getBetween(data_c[data_c.Length - 1], "\"", "=");
        //                }
        //                cursor = Utils.getBetween(data_c[8], "\"", "=");
        //                if (cursor.Contains("data-dedupekey"))
        //                {
        //                    cursor = "-" + cursor;
        //                    cursor = Utils.getBetween(cursor, "-", "\"");
        //                }

        //                string[] PagesLinkPagination = System.Text.RegularExpressions.Regex.Split(respReq, "<span>Suggested Post</span>");

        //                foreach (var item in PagesLinkPagination)
        //                {
        //                    pageSouceSplitPagination.Add(item);
        //                }

        //                PagesLink = System.Text.RegularExpressions.Regex.Split(respReq, "uiLikePageButton");
        //                foreach (var item in PagesLink)
        //                {
        //                    pageSouceSplitPagination.Add(item);
        //                }


        //                foreach (var item_pageSouceSplit in pageSouceSplit)
        //                {
        //                    try
        //                    {
        //                        if (item_pageSouceSplit.Contains("<!DOCTYPE html>"))
        //                        {
        //                            continue;
        //                        }
        //                        Dictionary<string, string> listContent = ScrapHasTagPages(item_pageSouceSplit);
        //                        Domain.Socioboard.Domain.Boardfbfeeds fbfeed = new Domain.Socioboard.Domain.Boardfbfeeds();
        //                        fbfeed.Id = Guid.NewGuid();
        //                        fbfeed.Isvisible = true;
        //                        fbfeed.Message = listContent["Message"];
        //                        fbfeed.Image = listContent["PostImage"];
        //                        fbfeed.Description = listContent["Title"];
        //                        string[] splitdate = System.Text.RegularExpressions.Regex.Split(listContent["Time"], "at");
        //                        string d = splitdate[0].Trim();
        //                        string t = splitdate[1].Trim();
        //                        fbfeed.Createddate = Convert.ToDateTime(d + " " + t);
        //                        fbfeed.Feedid = listContent["PostId"];
        //                        fbfeed.Type = listContent["Type"];
        //                        fbfeed.Type = listContent["Link"];
        //                        fbfeed.Fbpageprofileid = BoardfbPageId;
        //                        if (!boardrepo.checkFacebookFeedExists(fbfeed.Feedid, BoardfbPageId))
        //                        {
        //                            boardrepo.addBoardFbPageFeed(fbfeed);
        //                        }
        //                        // Please Write Code get Dictionary data 

        //                        //

        //                    }
        //                    catch { };



        //                }

        //            }
        //            catch (Exception ex)
        //            { //GlobusLogHelper.log.Error(ex.StackTrace); 
        //            }
        //        }
        //    }
        //    catch
        //    { }





        //}



        //public Dictionary<string, string> ScrapHasTagPages(string Value)
        //{
        //    string redirectionHref = string.Empty;
        //    string title = string.Empty;
        //    List<string[]> Likedata = new List<string[]>();
        //    Dictionary<string, string> HasTagData = new Dictionary<string, string>();
        //    //  foreach (var Value in Likepages)
        //    {
        //        try
        //        {

        //            redirectionHref = Utils.getBetween(Value, "href=\"", "\"");
        //            string profileUrl = redirectionHref;//1
        //            if (redirectionHref.Contains("https://www.facebook.com"))
        //            {

        //                string[] Arr_Title = System.Text.RegularExpressions.Regex.Split(Value, "<span class=\"fwb fcg\"");
        //                foreach (var valuetitle in Arr_Title)
        //                {
        //                    try
        //                    {


        //                        // title = Utils.getBetween(valuetitle, "<a", "/a>");
        //                        title = Utils.getBetween(valuetitle, "\">", "/a>");
        //                        if (!title.Equals(string.Empty))
        //                        {
        //                            title = Utils.getBetween(title, "\">", "<");
        //                            if (!string.IsNullOrEmpty(title))
        //                            {
        //                                break;
        //                            }

        //                        }
        //                    }
        //                    catch (Exception)
        //                    {

        //                    }
        //                }
        //                string profileName = title;//2
        //                string Message = Utils.getBetween(Value, "<p>", "<").Replace("&#064;", "@").Replace("&amp;", "&").Replace("u0025", "%");//7

        //                string[] timeDetails = Regex.Split(Value, "<abbr");
        //                string postedTime = string.Empty;
        //                try
        //                {
        //                    postedTime = Utils.getBetween(timeDetails[1], "=\"", "\"");
        //                }
        //                catch { };
        //                string postid = string.Empty;

        //                try
        //                {
        //                    postid = Utils.getBetween(timeDetails[0], "fbid=", "&amp;");
        //                    if (postid == "")
        //                    {
        //                        postid = Utils.getBetween(timeDetails[0], "/posts/", "\" target=");
        //                    }
        //                }
        //                catch
        //                {
        //                }

        //                string[] DetailedInfo = System.Text.RegularExpressions.Regex.Split(Value, "<div class=\"_6m7\">");
        //                string detail = string.Empty;
        //                try
        //                {
        //                    detail = "-" + DetailedInfo[1];//8
        //                    detail = Utils.getBetween(detail, "-", "</div>").Replace("&amp;", "&").Replace("u0025", "%");
        //                    if (detail.Contains("<a "))
        //                    {
        //                        string GetVisitUrl = Utils.getBetween(detail, "\">", "</a>");
        //                        detail = Utils.getBetween("$$$####" + detail, "$$$####", "<a href=") + "-" + GetVisitUrl;
        //                    }
        //                }
        //                catch
        //                { };

        //                string[] ArrDetail = System.Text.RegularExpressions.Regex.Split(Value, "<div class=\"mbs _6m6\">");
        //                string Titles = string.Empty;
        //                // string Url = Utils.getBetween(ArrDetail[0], "", "");
        //                try
        //                {
        //                    Titles = Utils.getBetween(ArrDetail[1], ">", "</a>").Replace("&#064;", "@").Replace("&amp;", "&").Replace("u0025", "%");//6
        //                    if (Titles.Contains("Sachin Tendulkar"))
        //                    {

        //                    }
        //                }
        //                catch { };
        //                string SiteRedirectionUrl = string.Empty;
        //                try
        //                {
        //                    SiteRedirectionUrl = Utils.getBetween(ArrDetail[1], "LinkshimAsyncLink.swap(this, &quot;", ");");
        //                }
        //                catch { };
        //                try
        //                {
        //                    SiteRedirectionUrl = Uri.UnescapeDataString(SiteRedirectionUrl).Replace("\\u0025", "%").Replace("\\", "");//4
        //                }
        //                catch { };
        //                string websiteUrl = string.Empty;
        //                try
        //                {
        //                    websiteUrl = Utils.getBetween(SiteRedirectionUrl, "//", "/");
        //                }
        //                catch { };
        //                string redirectionImg = string.Empty;
        //                try
        //                {
        //                    string[] adImg = System.Text.RegularExpressions.Regex.Split(Value, "<img class=\"scaledImageFitWidth img\"");
        //                       redirectionImg = Utils.getBetween(adImg[1], "src=\"", "\"").Replace("&amp;", "&");
        //                }
        //                catch { };


        //                string[] profImg = System.Text.RegularExpressions.Regex.Split(Value, "<img class=\"_s0 5xib 5sq7 _rw img\"");
        //                string profileImg = string.Empty;
        //                try
        //                {
        //                    profileImg = Utils.getBetween(profImg[0], "src=\"", "\"").Replace("&amp;", "&");
        //                }
        //                catch { };
        //                HasTagData.Add("Title", title);
        //                HasTagData.Add("Time", postedTime);
        //                HasTagData.Add("Type", "link");
        //                HasTagData.Add("Message", Message);
        //                HasTagData.Add("Image", profileImg);
        //                HasTagData.Add("PostImage", redirectionImg);
        //                HasTagData.Add("PostId", postid);
        //                HasTagData.Add("Link", SiteRedirectionUrl);
        //            }
        //        }
        //        catch { };
        //    }

        //    return HasTagData;
        //}

        public void ScraperHasTage(string Hash, Guid BoardfbPageId)
        {


            GlobusHttpHelper HttpHelper = new GlobusHttpHelper();
            string KeyWord = Hash;
            string pageSource_Home = HttpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/hashtag/" + KeyWord));
            List<string> pageSouceSplit = new List<string>();
            string[] PagesLink = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "_4-u2 mbm _5jmm _5pat _5v3q _4-u8");
            foreach (var item in PagesLink)
            {
                pageSouceSplit.Add(item);
            }
            PagesLink = PagesLink.Skip(1).ToArray();

            foreach (var item_pageSouceSplit in pageSouceSplit)
            {
                try
                {
                    if (item_pageSouceSplit.Contains("<!DOCTYPE html>"))
                    {
                        continue;
                    }
                    Dictionary<string, string> listContent = ScrapHasTagPages(item_pageSouceSplit);
                    Domain.Socioboard.Domain.Boardfbfeeds fbfeed = new Domain.Socioboard.Domain.Boardfbfeeds();
                    fbfeed.Id = Guid.NewGuid();
                    fbfeed.Isvisible = true;
                    fbfeed.Message = listContent["Message"];
                    fbfeed.Image = listContent["PostImage"];
                    fbfeed.Description = listContent["Title"];
                    string[] splitdate = System.Text.RegularExpressions.Regex.Split(listContent["Time"], "at");
                    string d = splitdate[0].Trim();
                    string t = splitdate[1].Trim();
                    fbfeed.Createddate = Convert.ToDateTime(d + " " + t);
                    fbfeed.Feedid = listContent["PostId"];
                    fbfeed.Type = listContent["Type"];
                    fbfeed.Link = listContent["Link"];
                    fbfeed.FromId = listContent["FromId"];
                    fbfeed.FromName = listContent["FromName"];
                    fbfeed.Fbpageprofileid = BoardfbPageId;
                    if (!boardrepo.checkFacebookFeedExists(fbfeed.Feedid, BoardfbPageId))
                    {
                        boardrepo.addBoardFbPageFeed(fbfeed);
                    }

                    // Please Write Code get Dictionary data 

                    //


                }
                catch { };



            }

        }