示例#1
0
        async void LoginId()
        {
            string[] baseUsername = null;
            try
            {
                baseUsername = File.ReadAllLines(setting.Convert_OriginalFileName);
            }
            catch
            {
                info.File = "Ошибка чтения из файла, пожалуйста, проверьте корректность введенных данных";
            }
            listId = new List <string>();
            int progress = 0;

            info.Progress = $"{progress}/{baseUsername.Length}";
            info.Status   = "Выполняется";
            info.File     = setting.Convert_OriginalFileName;
            EventUpdateGrid(this, new UpdateGridAudience(info));
            if (baseUsername != null)
            {
                foreach (string username in baseUsername)
                {
                    if (_source == null || _source.IsCancellationRequested)
                    {
                        break;
                    }
                    ew.WaitOne();
                    IResult <InstaUserInfo> infoUser = null;
                    try
                    {
                        infoUser = await api.GetUserInfoByUsernameAsync(username);

                        listId.Add(Convert.ToString(infoUser.Value.Pk));
                        progress++;
                        info.Progress = $"{progress}/{baseUsername.Length}";
                        EventUpdateGrid(this, new UpdateGridAudience(info));
                        Thread.Sleep(600);
                    }
                    catch
                    {
                        Thread.Sleep(6000);
                        continue;
                    }
                }
            }

            try
            {
                File.WriteAllLines(setting.Convert_SaveFileName, listId.ToArray());
            }
            catch
            {
                info.File = "Ошибка записи в файл, пожалуйста, проверьте корректность введенных данных";
            }

            info.Status = "Выполнено";
            EventUpdateGrid(this, new UpdateGridAudience(info));
        }
示例#2
0
        public async void ScrapeUser(string username)
        {
            //followers.Add(username);
            //Console.WriteLine("############################## USER {0} ###################################", username);
            //IResult<InstaUser> userSearch = await api.GetUserAsync(username);
            var task = api.GetUserAsync(username);
            IResult <InstaUser> userSearch = task.GetAwaiter().GetResult();

            Thread.Sleep(2000);
            //Console.WriteLine($"USER: {userSearch.Value.FullName}\n\tUserName: {userSearch.Value.UserName}\n\tFollowers: {userSearch.Value.FollowersCount}\n\tVerified: {userSearch.Value.IsVerified}\n\tBio: {userSearch.Value.FollowersCount}");

            //IResult<InstaUserInfo> userInfo = await api.GetUserInfoByUsernameAsync(username);
            var task1 = api.GetUserInfoByUsernameAsync(username);
            IResult <InstaUserInfo> userInfo = task1.GetAwaiter().GetResult();

            Thread.Sleep(2000);
            //Console.WriteLine($"BioGraphy: {userInfo.Value.Biography}");
            string phone = "", eMail = "";

            foreach (var line in userInfo.Value.Biography.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
            {
                string phoneNumber = GetPhoneNumber(line);
                phone = phoneNumber;

                const string MatchEmailPattern =
                    @"(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
                    + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
                    + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
                    + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})";
                Regex           rx          = new Regex(MatchEmailPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
                MatchCollection matches     = rx.Matches(line);
                int             noOfMatches = matches.Count;

                foreach (Match match in matches)
                {
                    if (string.IsNullOrEmpty(eMail))
                    {
                        eMail = match.Value.ToString();
                    }
                    else
                    {
                        eMail += "," + match.Value.ToString();
                    }
                }
            }
            if (!string.IsNullOrEmpty(eMail))
            {
                User usr = new User(userSearch.Value.FullName, eMail, userSearch.Value.UserName, phone);
                users.Add(usr);
            }
        }
示例#3
0
        public async Task <IResult <InstaFriendshipStatus> > Subscribe(string uri)
        {
            var userInfo = await _instaApi.GetUserInfoByUsernameAsync("uri");

            return(await _instaApi.FollowUserAsync(userInfo.Value.Pk));
        }
示例#4
0
        async void Sbor()
        {
            string[] baseId = null;
            try
            {
                baseId = File.ReadAllLines(setting.Filter_FileNameId);
            }
            catch
            {
                info.Status = "Ошибка чтения файла базой";
            }
            info.File = setting.Filter_SaveFileName;
            int progress = 0;

            if (baseId != null)
            {
                info.Progress = $"{progress}/{baseId.Length}";
            }
            EventUpdateGrid(this, new UpdateGridAudience(info));

            foreach (string id in baseId)
            {
                try
                {
                    if (_source == null || _source.IsCancellationRequested)
                    {
                        break;
                    }

                    var user = await api.GetUserInfoByUsernameAsync(id);

                    ew.WaitOne();
                    if (user.Succeeded && user != null)
                    {
                        if (setting.Filter_CheckedFollowers)
                        {
                            if (setting.Filter_Followers_Min > user.Value.FollowerCount ||
                                setting.Filter_Followers_Max < user.Value.FollowerCount)
                            {
                                progress++;
                                info.Progress = $"{progress}/{baseId.Length}";
                                EventUpdateGrid(this, new UpdateGridAudience(info));
                                Thread.Sleep(400);
                                continue;
                            }
                        }

                        if (setting.Filter_CheckedSubscriptions)
                        {
                            if (setting.Filter_Subscriptions_Min > user.Value.FollowingCount ||
                                setting.Filter_Subscriptions_Max < user.Value.FollowingCount)
                            {
                                progress++;
                                info.Progress = $"{progress}/{baseId.Length}";
                                EventUpdateGrid(this, new UpdateGridAudience(info));
                                Thread.Sleep(400);
                                continue;
                            }
                        }

                        if (setting.Filter_CheckedPublish)
                        {
                            if (setting.Filter_Publish_Min > user.Value.MediaCount ||
                                setting.Filter_Publish_Max < user.Value.MediaCount)
                            {
                                progress++;
                                info.Progress = $"{progress}/{baseId.Length}";
                                EventUpdateGrid(this, new UpdateGridAudience(info));
                                Thread.Sleep(400);
                                continue;
                            }
                        }

                        if (setting.Filter_CheckedOldDays)
                        {
                            var mediaList =
                                await api.GetUserMediaAsync(user.Value.Username,
                                                            PaginationParameters.MaxPagesToLoad(1));

                            if (mediaList.Succeeded && mediaList.Value[0] != null)
                            {
                                if ((DateTime.Now - mediaList.Value[0].Caption.CreatedAt).Days > setting.Filter_OldDays)
                                {
                                    progress++;
                                    info.Progress = $"{progress}/{baseId.Length}";
                                    EventUpdateGrid(this, new UpdateGridAudience(info));
                                    Thread.Sleep(400);
                                    continue;
                                }
                            }
                        }

                        if (setting.Filter_WhatAccPars == WhatAccPars.onlyPublic && user.Value.IsPrivate)
                        {
                            progress++;
                            info.Progress = $"{progress}/{baseId.Length}";
                            EventUpdateGrid(this, new UpdateGridAudience(info));
                            Thread.Sleep(400);
                            continue;
                        }

                        if (setting.Filter_WhatAccPars == WhatAccPars.onlyPrivate && !user.Value.IsPrivate)
                        {
                            progress++;
                            info.Progress = $"{progress}/{baseId.Length}";
                            EventUpdateGrid(this, new UpdateGridAudience(info));
                            Thread.Sleep(400);
                            continue;
                        }

                        if (setting.Filter_CheckedAvatar && user.Value.HasAnonymousProfilePicture)
                        {
                            progress++;
                            info.Progress = $"{progress}/{baseId.Length}";
                            EventUpdateGrid(this, new UpdateGridAudience(info));
                            Thread.Sleep(400);
                            continue;
                        }

                        if (setting.Filter_CheckedBusines && user.Value.IsBusiness)
                        {
                            progress++;
                            info.Progress = $"{progress}/{baseId.Length}";
                            EventUpdateGrid(this, new UpdateGridAudience(info));
                            listAccBusines.Add(user.Value.Username);
                        }

                        listAcc.Add(user.Value.Username);
                        info.Progress = $"{progress}/{baseId.Length}";
                        EventUpdateGrid(this, new UpdateGridAudience(info));
                        Thread.Sleep(400);
                    }
                    else
                    {
                        Thread.Sleep(6000);
                    }
                }
                catch
                {
                    continue;
                }
            }
            info.Status   = "Выполнено";
            info.Progress = $"{progress}/{baseId.Length}";
            EventUpdateGrid(this, new UpdateGridAudience(info));
            Save();
        }