Exemplo n.º 1
0
        public async Task <List <CheckFbCredentialOutput> > RunScenario(IList <CheckFbCredentialInput> listCheckFbCredentialInput)
        {
            var listCheckFbCredentialOutput = new List <CheckFbCredentialOutput>(listCheckFbCredentialInput.Count);

            foreach (var credential in listCheckFbCredentialInput)
            {
                try
                {
                    using (var browser = await PuppeteerBrowser.GetBrowser(_chromiumSettings.GetPath(), _chromiumSettings.GetHeadless()))
                        using (var page = await browser.NewPageAsync())
                        {
                            var pageUrl = await FbAuthorization.Auth(page, new EmailAccountData { Phone = credential.Login, Password = credential.Password });

                            var checkFbCredentialOutput = new CheckFbCredentialOutput
                            {
                                Login     = credential.Login,
                                Password  = credential.Password,
                                IsSuccess = !string.IsNullOrEmpty(pageUrl),
                                Url       = pageUrl
                            };
                            listCheckFbCredentialOutput.Add(checkFbCredentialOutput);
                            _progressResult?.Report(checkFbCredentialOutput);
                            Info(JsonConvert.SerializeObject(checkFbCredentialOutput));
                        }
                }
                catch (Exception exception)
                {
                    Error(exception.Message);
                }
            }
            return(listCheckFbCredentialOutput);
        }
Exemplo n.º 2
0
        public async Task <List <string> > RunScenario(IAccountData accountData, string[] fbAccountNames)
        {
            var result = new List <string>();

            try
            {
                using (var browser = await PuppeteerBrowser.GetBrowser(_chromiumSettings.GetPath(), _chromiumSettings.GetHeadless()))
                    using (var page = await browser.NewPageAsync())
                    {
                        if (accountData != null)
                        {
                            var fbAuthorizationAuth = await FbAuthorization.Auth(page, accountData);

                            Info($"Авторизация Фейсбук - {fbAuthorizationAuth}");
                        }
                        else
                        {
                            Info("Нет данных для авторизация Фейсбук");
                        }
                        foreach (var fbAccountName in fbAccountNames)
                        {
                            if (string.IsNullOrEmpty(fbAccountName))
                            {
                                continue;
                            }
                            var response = await page.GoToAsync($"https://www.facebook.com/{fbAccountName}");

                            var checkFbAccountResult = new CheckFbAccountOutput
                            {
                                AccountName = fbAccountName,
                                Available   = response.Ok
                            };
                            _progressResult?.Report(checkFbAccountResult);
                            var text = JsonConvert.SerializeObject(checkFbAccountResult);
                            Info(text);
                            result.Add(text);
                        }
                    }
            }
            catch (Exception exception)
            {
                Error(exception.Message);
            }
            return(result);
        }