Example #1
0
        public void startUserScraper(string itemHash, int delay)
        {
            string pageSource = string.Empty;
            string response = string.Empty;
            string postData = string.Empty;
            List<string> lstCountScrapUser = new List<string>();

            if (stopScrapBool) return;
            try
            {
                GlobDramProHttpHelper _GlobusHttpHelper = new GlobDramProHttpHelper();
                pageSource = _GlobusHttpHelper.getHtmlfromUrl(new Uri(mainUrl),"");
                if (!string.IsNullOrEmpty(pageSource))
                {
                    //if (itemHash.StartsWith("#"))
                    //{
                    //    postData = "q=" + Uri.EscapeDataString(itemHash);
                    //}
                    //else
                    //{
                    //    postData = "q=" + Uri.EscapeDataString("#") + itemHash;
                    //}

                    postData = "q=" + Uri.EscapeDataString(itemHash);
                    string url = "http://websta.me/search/" + postData.Substring(postData.IndexOf("=") + 1);
                    string referer = "http://websta.me/";
                    response = _GlobusHttpHelper.postFormData(new Uri(url), postData, referer, "");

                    if (!string.IsNullOrEmpty(response))
                    {
                        if (response.Contains("class=\"username\""))
                        {
                            try
                            {
                                string[] arrOfUserName = Regex.Split(response, "class=\"username\"");

                                if (arrOfUserName.Length > 0)
                                {
                                    arrOfUserName = arrOfUserName.Skip(1).ToArray();
                                    foreach (string itemArray in arrOfUserName)
                                    {
                                        if (stopScrapBool) return;
                                        try
                                        {
                                            string startString = "href=\"/n/";
                                            string endString = "\">";
                                            if (itemArray.Contains(startString) && itemArray.Contains(endString))
                                            {
                                                string userName = string.Empty;
                                                try
                                                {
                                                    userName = getBetween(itemArray, startString, endString);
                                                    lstCountScrapUser.Add(userName);
                                                    lstCountScrapUser = lstCountScrapUser.Distinct().ToList();

                                                    if (!string.IsNullOrEmpty(userLink))
                                                    {
                                                        duplicateurl.Add(userLink + userName, userLink + userName);
                                                        #region CSV Write
                                                        try
                                                        {

                                                            string CSVData = itemHash.Replace(",", string.Empty) + "," + userName.Replace(",", string.Empty) + "," + (userLink + userName).Replace(",", string.Empty);
                                                            GramBoardProFileHelper.ExportDataCSVFile(CSVHeader, CSVData, CSVPath);
                                                        }
                                                        catch { }
                                                        try
                                                        {

                                                        GramBoardLogHelper.log.Info("["+ userName +","+ "itemHash:" +","+ itemHash +","+ "userName:"******","+ userName +","+ "userLink:" +","+ userLink + ","+" UserName" +userName +"]");

                                                        }
                                                        catch { };

                                                        #endregion

                                                        try
                                                        {
                                                            if (stopScrapBool) return;
                                                            lock (_lockObject)
                                                            {
                                                                try
                                                                {
                                                                    GramBoardLogHelper.log.Info("=> [  UserName" + userName + " ]");
                                                                    //HashLogger.printLogger("[ " + DateTime.Now + " ] => [ Delay for " + delay + " seconds ]");
                                                                    //GramBoardLogHelper.log.Info(" => [ Delay for " + delay + " seconds ]");
                                                                    //Thread.Sleep(delay * 1000);

                                                                    frm_stagram objfrm_stagram = (frm_stagram)Application.OpenForms["frm_stagram"];

                                                                    if (!string.IsNullOrEmpty(objfrm_stagram.txtDelayHashTag.Text) && NumberHelper.ValidateNumber(objfrm_stagram.txtDelayHashTag.Text))
                                                                    {
                                                                        mindelay = Convert.ToInt32(objfrm_stagram.txtDelayHashTag.Text);
                                                                    }
                                                                    if (!string.IsNullOrEmpty(objfrm_stagram.MinHashTagMinDelay.Text) && NumberHelper.ValidateNumber(objfrm_stagram.MinHashTagMinDelay.Text))
                                                                    {
                                                                        maxdelay = Convert.ToInt32(objfrm_stagram.MinHashTagMinDelay.Text);
                                                                    }

                                                                    Random obj_rn = new Random();
                                                                    int delay1 = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                                                                    delay1 = obj_rn.Next(mindelay, maxdelay);
                                                                    GramBoardLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Delay For " + delay1 + " Seconds ]");
                                                                    Thread.Sleep(delay1 * 1000);
                                                                }
                                                                catch { }
                                                            }
                                                            if (lstCountScrapUser.Count >= ClGlobul.countNOOfFollowersandImageDownload)
                                                            {
                                                                return;
                                                            }
                                                        }
                                                        catch { }
                                                    }
                                                }
                                                catch { }
                                            }
                                        }
                                        catch { }
                                    }
                                }
                            }
                            catch { }
                        }
                    }//End of if (!string.IsNullOrEmpty(response))
                    else
                    {
                        //Do Nothing yet
                    }

                }//End of if (!string.IsNullOrEmpty(pageSource))
            }
            catch { }
            //GlobusLogHelper.log.Info("[" + DateTime.Now + " ]=>[Process Completed]");
            //HashLogger.printLogger("[ " + DateTime.Now + " ] => [  Process Completed ]");
        }
        public string MyLoginForUnfollow(ref GlobDramProHttpHelper _GlobusHttpHelper, string url, string commentPostData, string referrer)
        {
            Log("[ " + DateTime.Now + " ] => [ Logging in with Account : " + Username + " ]");
            string Status = string.Empty;
            try
            {
                string firstUrl = "https://api.instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes";

                //https://instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes

                string secondURL = "https://instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes";

                string res_secondURL = string.Empty;

                if (!string.IsNullOrEmpty(proxyAddress) && !string.IsNullOrEmpty(proxyPort))
                {
                    try
                    {
                        res_secondURL = _GlobusHttpHelper.getHtmlfromUrlProxy(new Uri(secondURL), proxyAddress, Convert.ToInt32(proxyPort), proxyUsername, proxyPassword);
                    }
                    catch (Exception ex)
                    {

                    }
                }
                else
                {

                    try
                    {
                        res_secondURL = _GlobusHttpHelper.getHtmlfromUrlProxy(new Uri(secondURL), "", 80, "", "");
                    }
                    catch { }
                }

                string nextUrl = "https://instagram.com/accounts/login/?force_classic_login=&next=/oauth/authorize/%3Fclient_id%3D9d836570317f4c18bca0db6d2ac38e29%26redirect_uri%3Dhttp%3A//websta.me/%26response_type%3Dcode%26scope%3Dcomments%2Brelationships%2Blikes";
                string res_nextUrl = _GlobusHttpHelper.getHtmlfromUrl(new Uri("http://websta.me/login"), "");

                //Get Token Number of Id
                int FirstPointToken_nextUrl = res_nextUrl.IndexOf("csrfmiddlewaretoken");
                string FirstTokenSubString_nextUrl = res_nextUrl.Substring(FirstPointToken_nextUrl);
                int SecondPointToken_nextUrl = FirstTokenSubString_nextUrl.IndexOf("/>");
                this.Token = FirstTokenSubString_nextUrl.Substring(0, SecondPointToken_nextUrl).Replace("csrfmiddlewaretoken", string.Empty).Replace("value=", string.Empty).Replace("\"", string.Empty).Replace("'", string.Empty).Trim();

                string login = "******";
                string postdata_Login = "******" + this.Token + "&username="******"&password="******"";

                string res_postdata_Login = _GlobusHttpHelper.postFormData(new Uri(login), postdata_Login, login, "");

                if (res_postdata_Login.Contains("Please enter a correct username and password"))
                {
                    //Status = "Failed";
                    this.LoggedIn = false;
                }
                else if (res_postdata_Login.Contains("requesting access to your Instagram account") || postdata_Login.Contains("is requesting to do the following"))
                {
                    //Status = "AccessIssue";
                }
                else if (res_postdata_Login.Contains("logout") || postdata_Login.Contains("LOG OUT"))
                {
                    //Status = "Success";
                    string zone = string.Empty;
                    if (res_postdata_Login.Contains("data('userid'") && res_postdata_Login.Contains(")"))
                    {
                        try
                        {
                            zone = ScrapUserName.getBetween(res_postdata_Login, "data('userid'", ")");
                            if (!string.IsNullOrEmpty(zone))
                            {
                                try
                                {
                                    int start = zone.IndexOf("'");
                                    int end = zone.LastIndexOf("'");
                                    Status = zone.Substring(start + 1, end - start - 1);
                                }
                                catch { }
                            }
                        }
                        catch { }
                    }
                    Log("[ " + DateTime.Now + " ] => [ Logged in with Account :" + Username + " ]");
                    this.LoggedIn = true;

                }

                //nameval.Clear();
                return Status;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
Example #3
0
        public void startDownloadingImage(string itemImageTag)
        {
            try
            {
                Thread.CurrentThread.IsBackground = true;
                Lst_photoLikethread.Add(Thread.CurrentThread);
                Lst_photoLikethread = Lst_photoLikethread.Distinct().ToList();
            }
            catch (Exception ex)
            {
                GramBoardProFileHelper.AppendStringToTextfileNewLine("------------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForPhotolike);
                GramBoardProFileHelper.AppendStringToTextfileNewLine(DateTime.Now + ":=> Methode Name => unlike :=> " + ex.Message, GramBoardProFileHelper.ErrorLogFilePathForPhotolike);
                GramBoardProFileHelper.AppendStringToTextfileNewLine("------------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForPhotolike);

            }

            string pageSource = string.Empty;
            int counter = 0;
            GlobDramProHttpHelper objGlobusHttpHelper = new GlobDramProHttpHelper();
            List<string> lstCountImage = new List<string>();
            string url = string.Empty;
            string mainUrl = "http://websta.me/";
            if (IsDownLoadImageUsingHashTag)
            {
                url = mainUrl + "tag/" + itemImageTag.Replace("#",string.Empty);
                AddTophotoLogger("[ " + DateTime.Now + " ] =>[Process Using HashTag =" + itemImageTag);
            }

            else if (IsDownLoadImageUsingUserName)
            {
                url = mainUrl + "n/" + itemImageTag;
                AddTophotoLogger("[ " + DateTime.Now + " ] =>[Process Selected Using UserName  ="******"tag/" + itemImageTag;
                // AddTophotoLogger("Process Using HashTag =" + itemImageTag);
                AddTophotoLogger("[ " + DateTime.Now + " ] =>[Process Using HashTag" + itemImageTag);
            }

            try
            {
                pageSource = objGlobusHttpHelper.getHtmlfromUrl(new Uri(url),"");
            }
            catch { }

            if (string.IsNullOrEmpty(pageSource))
            {
                pageSource = objGlobusHttpHelper.getHtmlfromUrl(new Uri(url),"");
            }

            if (!string.IsNullOrEmpty(pageSource))
            {
                if (pageSource.Contains("<div class=\"mainimg_wrapper\">"))
                {
                    string[] arr = Regex.Split(pageSource, "<div class=\"mainimg_wrapper\">");
                    if (arr.Length > 1)
                    {
                        arr = arr.Skip(1).ToArray();

                        foreach (string itemarr in arr)
                        {

                            try
                            {
                                string startString = "<a href=\"";
                                string endString = "\" class=\"mainimg\"";
                                string imageId = string.Empty;
                                string imageSrc = string.Empty;
                                if (itemarr.Contains("<a href=\"/p/"))
                                {
                                    int indexStart = itemarr.IndexOf("<a href=\"/p/");
                                    string itemarrNow = itemarr.Substring(indexStart);
                                    if (itemarrNow.Contains(startString) && itemarrNow.Contains(endString))
                                    {
                                        try
                                        {
                                            //FileData
                                            imageId = getBetween(itemarrNow, startString, endString).Replace("/", "");
                                        }
                                        catch { }
                                        if (!string.IsNullOrEmpty(imageId))
                                        {
                                            //counter++;
                                            //imageId = "http://websta.me"+imageId;
                                        }
                                    }

                                    if (itemarrNow.Contains("<img src=\""))
                                    {
                                        try
                                        {
                                            imageSrc = getBetween(itemarrNow, "<img src=\"", "\"");
                                        }
                                        catch { }
                                        counter++;

                                        SaveImageWithUrl(imageSrc, FileData, imageId + "_" + counter);//FileData //Globals.imageDesktopPath

                                        lstCountImage.Add(imageSrc);
                                        lstCountImage = lstCountImage.Distinct().ToList();
                                        // AddTophotoLogger("Image DownLoaded with ImageName  " + imageId + "_" + counter);
                                        AddTophotoLogger("[ " + DateTime.Now + " ] =>[Image DownLoaded with user="******"_" + imageId + "_" + counter);
                                        if (!string.IsNullOrEmpty(delayimagemin.Text) && NumberHelper.ValidateNumber(delayimagemin.Text))
                                        {
                                            mindelay = Convert.ToInt32(delayimagemin.Text);
                                        }
                                        if (!string.IsNullOrEmpty(imagedelaymax.Text) && NumberHelper.ValidateNumber(imagedelaymax.Text))
                                        {
                                            maxdelay = Convert.ToInt32(imagedelaymax.Text);
                                        }
                                        lock (_lockObject)
                                        {
                                            int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                                            AddTophotoLogger("[ " + DateTime.Now + " ] => [ Delay For " + delay + " Seconds ]");
                                            Thread.Sleep(delay *1000);
                                        }

                                        if (lstCountImage.Count >= ClGlobul.countNOOfFollowersandImageDownload)
                                        {
                                            return;
                                        }

                                        try
                                        {

                                        }
                                        catch { }
                                    }
                                }
                            }
                            catch { }

                        }

                        #region pagination
                        string pageLink = string.Empty;
                        while (true)
                        {
                            //if (stopScrapImageBool) return;
                            string startString = "<a href=\"";
                            string endString = "\" class=\"mainimg\"";
                            string imageId = string.Empty;
                            string imageSrc = string.Empty;

                            if (!string.IsNullOrEmpty(pageLink))
                            {
                                pageSource = objGlobusHttpHelper.getHtmlfromUrl(new Uri(pageLink),"");
                                if (string.IsNullOrEmpty(pageSource))
                                {
                                    pageSource = objGlobusHttpHelper.getHtmlfromUrl(new Uri(pageLink),"");
                                }
                            }

                            if (pageSource.Contains("<ul class=\"pager\">") && pageSource.Contains("rel=\"next\">"))
                            {
                                try
                                {
                                    pageLink = getBetween(pageSource, "<ul class=\"pager\">", "rel=\"next\">");
                                }
                                catch { }
                                if (!string.IsNullOrEmpty(pageLink))
                                {
                                    try
                                    {
                                        int len = pageLink.IndexOf("<a href=\"");
                                        len = len + ("<a href=\"").Length;
                                        pageLink = pageLink.Substring(len);
                                        pageLink = pageLink.Trim();
                                        pageLink = pageLink.TrimEnd(new char[] { '"' });
                                        pageLink = "http://websta.me/" + pageLink;
                                    }
                                    catch { }
                                    if (!string.IsNullOrEmpty(pageLink))
                                    {
                                        string response = string.Empty;
                                        try
                                        {
                                            response = objGlobusHttpHelper.getHtmlfromUrl(new Uri(pageLink),"");
                                        }
                                        catch { }
                                        if (!string.IsNullOrEmpty(response))
                                        {
                                            if (response.Contains("<div class=\"mainimg_wrapper\">"))
                                            {
                                                try
                                                {
                                                    string[] arr1 = Regex.Split(response, "<div class=\"mainimg_wrapper\">");
                                                    if (arr1.Length > 1)
                                                    {
                                                        arr1 = arr1.Skip(1).ToArray();
                                                        foreach (string items in arr1)
                                                        {
                                                            try
                                                            {
                                                                //if (stopScrapImageBool) return;
                                                                if (items.Contains("<a href=\"/p/"))
                                                                {
                                                                    int indexStart = items.IndexOf("<a href=\"/p/");
                                                                    string itemarrNow = items.Substring(indexStart);

                                                                    try
                                                                    {
                                                                        imageId = getBetween(itemarrNow, startString, endString).Replace("/", "");
                                                                    }
                                                                    catch { }
                                                                    if (!string.IsNullOrEmpty(imageId))
                                                                    {
                                                                        //counter++;
                                                                        //imageId = "http://websta.me"+imageId;
                                                                    }

                                                                    if (itemarrNow.Contains("<img src=\""))
                                                                    {
                                                                        try
                                                                        {
                                                                            imageSrc = getBetween(itemarrNow, "<img src=\"", "\"");
                                                                        }
                                                                        catch { }
                                                                    }

                                                                    counter++;

                                                                    {
                                                                        SaveImageWithUrl(imageSrc, FileData, imageId + "_" + counter);
                                                                    }
                                                                    lstCountImage.Add(imageSrc);
                                                                    lstCountImage = lstCountImage.Distinct().ToList();
                                                                    //AddTophotoLogger("Image DownLoaded with ImageName  " + imageId + "_" + counter);
                                                                    AddTophotoLogger("[ " + DateTime.Now + " ] =>[Image DownLoaded with ImageName  " + imageId + "_" + counter);
                                                                    if (!string.IsNullOrEmpty(delayimagemin.Text) && NumberHelper.ValidateNumber(delayimagemin.Text))
                                                                    {
                                                                        mindelay = Convert.ToInt32(delayimagemin.Text);
                                                                    }
                                                                    if (!string.IsNullOrEmpty(imagedelaymax.Text) && NumberHelper.ValidateNumber(imagedelaymax.Text))
                                                                    {
                                                                        maxdelay = Convert.ToInt32(imagedelaymax.Text);
                                                                    }
                                                                    lock (_lockObject)
                                                                    {
                                                                        int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                                                                        AddToLogger("[ " + DateTime.Now + " ] => [ Delay For " + delay + " Seconds ]");
                                                                        Thread.Sleep(delay * 1000);
                                                                    }
                                                                    if (lstCountImage.Count >= ClGlobul.countNOOfFollowersandImageDownload)
                                                                    {
                                                                        return;
                                                                    }

                                                                }

                                                            }
                                                            catch { }
                                                        }
                                                        if (lstCountImage.Count >= ClGlobul.countNOOfFollowersandImageDownload)
                                                        {
                                                            return;
                                                        }
                                                    }
                                                }
                                                catch { }

                                            }
                                        }
                                        else
                                        {

                                        }

                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        #endregion

                    }
                }
            }
            if (!string.IsNullOrEmpty(pageSource))
            {
                url = mainUrl + "n/" + itemImageTag;
                AddTophotoLogger("[ " + DateTime.Now + " ] =>[" + itemImageTag  +  " = Username is Private, so unable to fetch Image ");

            }
            else
            {
                AddTophotoLogger("[ " + DateTime.Now + " ] =>[" + itemImageTag + " = This user does not exist.");
            }

            //else
            //{
            //    AddToLogger("[ " + DateTime.Now + " ] => [  No Image found.]");
            //    //return;
            //}
        }
Example #4
0
        public List<string> GetUser(string hashTag)
        {
            List<string> lstUser = new List<string>();
            try
            {
                string url = "http://websta.me/search/" + hashTag.Replace("#", "%23");
                GlobDramProHttpHelper objInstagramUser = new GlobDramProHttpHelper();

                string pageSource = objInstagramUser.getHtmlfromUrl(new Uri(url),"");
                if (string.IsNullOrEmpty(pageSource))
                {
                    pageSource = objInstagramUser.getHtmlfromUrl(new Uri(url),"");
                }

                if (!string.IsNullOrEmpty(pageSource))
                {
                    if (pageSource.Contains("username\" href="))
                    {
                        string ScrapUser = string.Empty;
                        string[] arr = Regex.Split(pageSource, "username\" href=");
                        if (arr.Length > 1)
                        {
                            arr = arr.Skip(1).ToArray();
                            foreach (string itemarr in arr)
                            {
                                try
                                {
                                    if (itemarr.Contains("<a href="))
                                    {
                                        ScrapUser = getBetween(itemarr, "", "</a>");
                                        string[] urldata = Regex.Split(ScrapUser, ">");
                                        string username = urldata[1];
                                        if (!string.IsNullOrEmpty(username))
                                        {
                                            lstUser.Add(username);
                                            lstUser = lstUser.Distinct().ToList();

                                            if (lstUser.Count >= ClGlobul.NumberOfProfilesToFollow)
                                            {
                                                return lstUser;
                                            }
                                        }
                                    }
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            return lstUser;
        }
Example #5
0
        public List<string> GetPhotoId1(string hashTag)
        {
            try
            {
                GloBoardPro.HasTagListListThread.Add(Thread.CurrentThread);
                GloBoardPro.HasTagListListThread.Distinct();
                Thread.CurrentThread.IsBackground = true;
            }
            catch
            {
            }

            //string url = "http://websta.me/" + "tag/" + hashTag;
            string url = "http://websta.me/" + "tag/" + hashTag.Replace("%23", "").Replace("#", "");
            GlobDramProHttpHelper objInstagramUser = new GlobDramProHttpHelper();
            List<string> lstPhotoId = new List<string>();

            string pageSource = objInstagramUser.getHtmlfromUrl(new Uri(url),"");
            if (string.IsNullOrEmpty(pageSource))
            {
                pageSource = objInstagramUser.getHtmlfromUrl(new Uri(url),"");
            }
            if (!string.IsNullOrEmpty(pageSource))
            {
                if (pageSource.Contains("<div class=\"mainimg_wrapper\">"))
                {
                    string[] arr = Regex.Split(pageSource, "<div class=\"mainimg_wrapper\">");
                    if (arr.Length > 1)
                    {
                        arr = arr.Skip(1).ToArray();
                        foreach (string itemarr in arr)
                        {
                            try
                            {
                                string startString = "<a href=\"/p/";
                                string endString = "\" class=\"mainimg\"";
                                string imageId = string.Empty;
                                string imageSrc = string.Empty;
                                if (itemarr.Contains("<a href=\"/p/"))
                                {
                                    int indexStart = itemarr.IndexOf("<a href=\"/p/");
                                    string itemarrNow = itemarr.Substring(indexStart);
                                    if (itemarrNow.Contains(startString) && itemarrNow.Contains(endString))
                                    {
                                        try
                                        {
                                            imageId = getBetween(itemarrNow, startString, endString).Replace("/", "");
                                        }
                                        catch { }
                                        if (!string.IsNullOrEmpty(imageId))
                                        {
                                            lstPhotoId.Add(imageId);
                                            lstPhotoId.Distinct();
                                            if (lstPhotoId.Count >= ClGlobul.NumberofSnapsVideosToComment)
                                            {
                                                return lstPhotoId;
                                            }

                                            //imageId = "http://websta.me"+imageId;
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {

                            }

                        }

                        #region pagination

                        string pageLink = string.Empty;
                        while (true)
                        {

                            try
                            {
                                GloBoardPro.HasTagListListThread.Add(Thread.CurrentThread);
                                GloBoardPro.HasTagListListThread.Distinct();
                                Thread.CurrentThread.IsBackground = true;
                            }
                            catch
                            {
                            }
                            //if (stopScrapImageBool) return;
                            string startString = "<a href=\"/p/";
                            string endString = "\" class=\"mainimg\"";
                            string imageId = string.Empty;
                            string imageSrc = string.Empty;

                            if (!string.IsNullOrEmpty(pageLink))
                            {
                                pageSource = objInstagramUser.getHtmlfromUrl(new Uri(pageLink),"");
                            }

                            if (pageSource.Contains("<ul class=\"pager\">") && pageSource.Contains("rel=\"next\">"))
                            {
                                try
                                {
                                    pageLink = getBetween(pageSource, "<ul class=\"pager\">", "rel=\"next\">");
                                }
                                catch { }
                                if (!string.IsNullOrEmpty(pageLink))
                                {
                                    try
                                    {
                                        int len = pageLink.IndexOf("<a href=\"");
                                        len = len + ("<a href=\"").Length;
                                        pageLink = pageLink.Substring(len);
                                        pageLink = pageLink.Trim();
                                        pageLink = pageLink.TrimEnd(new char[] { '"' });
                                        pageLink = "http://websta.me/" + pageLink;
                                    }
                                    catch { }
                                    if (!string.IsNullOrEmpty(pageLink))
                                    {
                                        string response = string.Empty;
                                        try
                                        {
                                            response = objInstagramUser.getHtmlfromUrl(new Uri(pageLink),"");
                                        }
                                        catch { }
                                        if (!string.IsNullOrEmpty(response))
                                        {
                                            if (response.Contains("<div class=\"mainimg_wrapper\">"))
                                            {
                                                try
                                                {
                                                    string[] arr1 = Regex.Split(response, "<div class=\"mainimg_wrapper\">");
                                                    if (arr1.Length > 1)
                                                    {
                                                        arr1 = arr1.Skip(1).ToArray();
                                                        foreach (string items in arr1)
                                                        {
                                                            try
                                                            {
                                                                //if (stopScrapImageBool) return;
                                                                if (items.Contains("<a href=\"/p/"))
                                                                {
                                                                    int indexStart = items.IndexOf("<a href=\"/p/");
                                                                    string itemarrNow = items.Substring(indexStart);

                                                                    try
                                                                    {
                                                                        imageId = getBetween(itemarrNow, startString, endString).Replace("/", "");
                                                                    }
                                                                    catch { }
                                                                    if (!string.IsNullOrEmpty(imageId))
                                                                    {
                                                                        lstPhotoId.Add(imageId);
                                                                        lstPhotoId.Distinct();
                                                                        if (lstPhotoId.Count >= ClGlobul.NumberofSnapsVideosToComment)
                                                                        {
                                                                            return lstPhotoId;
                                                                        }

                                                                        //imageId = "http://websta.me"+imageId;
                                                                    }

                                                                    //counter++;

                                                                    //Addtologger("Image DownLoaded with ImageName  "+imageId+"_"+counter);
                                                                    if (lstPhotoId.Count >= ClGlobul.NumberofSnapsVideosToComment)
                                                                    {
                                                                        return lstPhotoId;
                                                                    }
                                                                }
                                                            }

                                                            catch { }
                                                        }
                                                        if (lstPhotoId.Count >= ClGlobul.NumberofSnapsVideosToComment)
                                                        {
                                                            return lstPhotoId;
                                                        }
                                                    }
                                                }
                                                catch { }

                                            }
                                        }
                                        else
                                        {

                                        }

                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        #endregion
                    }
                }
            }

            return lstPhotoId;
        }
Example #6
0
        public void startDownloadingImage(string itemImageTag, int delay)
        {
            string pageSource = string.Empty;
            List<string> lstCountScrape = new List<string>();
            if (stopScrapImageBool) return;
            //try
            //{
            GlobDramProHttpHelper _GlobusHttpHelper = new GlobDramProHttpHelper();
            try
            {
                pageSource = _GlobusHttpHelper.getHtmlfromUrl(new Uri(mainUrl),"");
            }
            catch { }
            string url = string.Empty;
            if (!string.IsNullOrEmpty(pageSource))
            {
                if (itemImageTag.Contains("#"))
                {
                    itemImageTag = itemImageTag.Replace("#", "%23");
                    url = mainUrl + "tag/" + itemImageTag.Replace("%23", string.Empty);
                }
                else
                {
                    url = mainUrl + "n/" + itemImageTag.Replace("%23", string.Empty);
                }
                try
                {
                    pageSource = _GlobusHttpHelper.getHtmlfromUrl(new Uri(url),"");
                }
                catch { }
                if (!string.IsNullOrEmpty(pageSource))
                {
                    // if (pageSource.Contains("<div class=\"mainimg_wrapper\">"))
                    if (pageSource.Contains("class=\"username\""))
                    {
                        try
                        {

                            // string[] arr = Regex.Split(pageSource, "<div class=\"mainimg_wrapper\">");
                            string[] arr = Regex.Split(pageSource, "class=\"username\"");
                            if (arr.Length > 1)
                            {
                                arr = arr.Skip(1).ToArray();
                                foreach (var item in arr)
                                {
                                    string websiteLink = ScrapUserName.getBetween(item, "<a href=\"", "\"");
                                    websiteLink = "http://websta.me/" + websiteLink;
                                    string imageLink = ScrapUserName.getBetween(item, "src=\"", "\"");
                                    string imageid = ScrapUserName.getBetween(item, ".2885-19/", "_a.jpg\">");
                                    string FullName = ScrapUserName.getBetween(item, "\">", "</a>");
                                    lstCountScrape.Add(imageLink);
                                    lstCountScrape = lstCountScrape.Distinct().ToList();

                                    if (stopScrapImageBool) return;
                                    try
                                    {
                                        if (!string.IsNullOrEmpty(imageLink))
                                        {
                                            duplicatlink.Add(imageLink, imageid);

                                            string CSVData = websiteLink.Replace(",", string.Empty) + "," + imageLink.Replace(",", string.Empty) + "," + imageid.Replace(",", string.Empty) + "," + FullName.Replace(",", string.Empty);
                                            GramBoardProFileHelper.ExportDataCSVFile(CSVHeader, CSVData, CSVPath);
                                            classsforlogger objclasssforlogger = new classsforlogger();
                                            objclasssforlogger.AddToImageTagLogger("[ " + DateTime.Now + " ] => [ websiteLink : " + websiteLink + "   imageLink : " + imageLink + "   imageid : " + imageid + "   FullName : " + FullName);

                                            //frm_stagram objbbbFrmMain = (frm_stagram)Application.OpenForms["frm_stagram"];
                                            //objbbbFrmMain.lstImageLogger.Items.Add("hey ram");
                                            if (lstCountScrape.Count >= ClGlobul.countNOOfFollowersandImageDownload)
                                            {
                                                return;
                                            }
                                        }
                                    }
                                    catch { }
                                    if (stopScrapImageBool) return;
                                    try
                                    {
                                        classsforlogger objclasssforlogger = new classsforlogger();

                                        lock (_lockObject)
                                        {
                                            try
                                            {

                                                frm_stagram objfrm_stagram = (frm_stagram)Application.OpenForms["frm_stagram"];

                                                if (!string.IsNullOrEmpty(objfrm_stagram.txtmaxDelayGetImageImage.Text) && NumberHelper.ValidateNumber(objfrm_stagram.txtmaxDelayGetImageImage.Text))
                                                {
                                                    mindelay = Convert.ToInt32(objfrm_stagram.txtmaxDelayGetImageImage.Text);
                                                }
                                                if (!string.IsNullOrEmpty(objfrm_stagram.txtminDelayGetImageImage.Text) && NumberHelper.ValidateNumber(objfrm_stagram.txtminDelayGetImageImage.Text))
                                                {
                                                    maxdelay = Convert.ToInt32(objfrm_stagram.txtminDelayGetImageImage.Text);
                                                }

                                                Random obj_rn = new Random();
                                                int delay1 = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                                                delay1 = obj_rn.Next(mindelay, maxdelay);
                                                objclasssforlogger.AddToImageTagLogger("[ " + DateTime.Now + " ] => [ Delay For " + delay1 + " Seconds ]");
                                                Thread.Sleep(delay1 * 1000);
                                            }
                                            catch { }
                                        }

                                        //HashLogger.printLogger("[ " + DateTime.Now + " ] => [ " + imageId + " ]");
                                        //HashLogger.printLogger("[ " + DateTime.Now + " ] => [ Delay for " + delay + " seconds ]");
                                        objclasssforlogger.AddToImageTagLogger("[ " + DateTime.Now + " ] => [ " + websiteLink + " ]");
                                        //objclasssforlogger.AddToImageTagLogger("[ " + DateTime.Now + " ] => [ Delay for " + delay + " seconds ]");
                                        //Thread.Sleep(delay * 1000);

                                        if (lstCountScrape.Count >= ClGlobul.countNOOfFollowersandImageDownload)
                                        {
                                            return;
                                        }
                                    }
                                    catch { };
                                }
                            }

                             if (lstCountScrape.Count >= ClGlobul.countNOOfFollowersandImageDownload)
                             {
                                 return;
                             }

                        }
                        catch { };
                    }
                }
            }

            classsforlogger objclasssforlogger1 = new classsforlogger();
            objclasssforlogger1.AddToImageTagLogger("[ " + DateTime.Now + " ] => [ Process Completed ]");
        }