예제 #1
0
        /// <summary>
        /// resolves captcha if found
        /// </summary>
        public async Task ResolveCaptchaAsync()
        {
            AudioTrials = 0;

            _log.Called();

            try
            {
                if (StopCT.IsCancellationRequested)
                {
                    StopCT.ThrowIfCancellationRequested();                                 //cancellation
                }
                VerifyClickerInput();

                await _scrapService.TurnOffAlertsAsync(WebBrowser);

                if (SearchViaTor && HowManySearches == _torSearchesCaptchaLimit)
                {
                    GetNewIp(WebBrowser);
                }
                else
                {
                    Pause(); //if paused

                    await _scrapService.ClickCheckboxIcon(ClickerInput);

                    Pause();                 //if paused

                    await Task.Delay(10000); //wait for pics to load JS pics

                    if (StopCT.IsCancellationRequested)
                    {
                        StopCT.ThrowIfCancellationRequested();                                 //cancellation
                    }
                    bool isCaptcha = await _scrapService.CheckForRecaptchaAsync(WebBrowser);

                    if (isCaptcha)
                    {
                        await _scrapService.ClickAudioChallangeIconAsync(ClickerInput);

                        await ResolveAudioChallengeAsync();
                    }
                    else
                    {
                        await GetAndSaveResultAsync();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error(e.Message);
            }
        }
예제 #2
0
        /// <summary>
        /// resolves audio captcha
        /// </summary>
        public async Task ResolveAudioChallengeAsync()
        {
            _log.Called();

            try
            {
                Pause();                //if paused

                await Task.Delay(5000); //wait to load JS window

                if (StopCT.IsCancellationRequested)
                {
                    StopCT.ThrowIfCancellationRequested();                                 //cancellation
                }
                bool isCaptcha = await _scrapService.CheckForRecaptchaAsync(WebBrowser);

                if (isCaptcha)
                {
                    if (AudioTrials == _audioTrialsLimit)
                    {
                        if (SearchViaTor)
                        {
                            GetNewIp(WebBrowser);
                        }
                        else
                        {
                            ChangeConnectionType(WebBrowser);
                        }
                    }
                    else
                    {
                        await RecordAndProcessAudioAsync();

                        AudioTrials++;

                        _log.Info(AudioTrials.ToString());
                    }
                }
                else
                {
                    //log that no more captcha
                }
            }
            catch (Exception e)
            {
                _log.Error(e.Message);
            }
        }
예제 #3
0
        /// <summary>
        /// sending audio result
        /// </summary>
        /// <param name="audioResult">result of audio processing</param>
        public async Task SendAudioResultAsync(string audioResult)
        {
            _log.Called(audioResult);

            try
            {
                if (StopCT.IsCancellationRequested)
                {
                    StopCT.ThrowIfCancellationRequested();                                 //cancellation
                }
                audioResult = _fileService.ProsessText(audioResult);

                Pause(); //if paused

                await _scrapService.ClickTextBoxAsync(ClickerInput);

                Pause(); //if paused

                await _scrapService.EnterResultAsync(ClickerInput, audioResult);

                await Task.Delay(6000); //wait for audio challenge result

                bool isCaptcha = await _scrapService.CheckForRecaptchaAsync(WebBrowser);

                if (isCaptcha)
                {
                    InputCorrection = true;

                    await ResolveAudioChallengeAsync();
                }
                else
                {
                    //log

                    await GetAndSaveResultAsync();
                }
            }
            catch (Exception e)
            {
                _log.Error(e.Message);
            }
        }
예제 #4
0
        /// <summary>
        /// recording and processing audio
        /// </summary>
        public async Task RecordAndProcessAudioAsync()
        {
            _log.Called();

            try
            {
                Pause(); //if paused

                if (StopCT.IsCancellationRequested)
                {
                    StopCT.ThrowIfCancellationRequested();                                 //cancellation
                }
                await _scrapService.ClickPlayIconAsync(ClickerInput, InputCorrection);

                await _audioService.RecordAudioSampleAsync();

                string audioResult = await _audioService.ProcessAudioSampleAsync();

                if (string.IsNullOrEmpty(audioResult))
                {
                    //log

                    await MakeNewAudioChallengeAsync();
                }
                else
                {
                    //log

                    await SendAudioResultAsync(audioResult);
                }
            }
            catch (Exception e)
            {
                _log.Error(e.Message);
            }
        }
예제 #5
0
        /// <summary>
        /// gets new record to be saved
        /// </summary>
        public async Task GetNewRecordAsync()
        {
            _log.Called();

            string phrase = SearchPhrase.Replace("<name>", NameList[PhraseNo]);

            LoadingPage = true;
            HowManySearches++;

            WebBrowser.Load("https://www.google.com/");

            _pageLoadedEventHandler = async(sender, args) =>
            {
                if (args.IsLoading == false)
                {
                    WebBrowser.LoadingStateChanged -= _pageLoadedEventHandler;

                    try
                    {
                        if (StopCT.IsCancellationRequested)
                        {
                            StopCT.ThrowIfCancellationRequested(); //cancellation
                        }
                        Pause();                                   //if paused

                        await _scrapService.EnterPhraseAsync(ClickerInput, WebBrowser, phrase);

                        Pause(); //if paused

                        await _scrapService.ClickSearchBtnAsync(ClickerInput, WebBrowser);

                        Pause(); //if paused

                        bool isCaptcha = await CheckForCaptchaAsync();

                        Pause(); //if paused

                        if (!isCaptcha)
                        {
                            await GetAndSaveResultAsync();
                        }
                        else
                        {
                            throw new Exception("Captcha detected");
                        }

                        Pause(); //if paused
                    }
                    catch (OperationCanceledException e)
                    {
                        _log.Info("Method STOP cancelled: " + e.Message);
                    }
                    catch (Exception e)
                    {
                        if (e.Message == "Captcha detected" && !StopCT.IsCancellationRequested)
                        {
                            _log.Info(e.Message);

                            ClickerInput = true;

                            await ResolveCaptchaAsync();

                            ClickerInput = false;
                        }
                        else
                        {
                            _log.Error(e.Message);
                        }
                    }
                    finally
                    {
                        LoadingPage = false;
                    }
                }
            };

            WebBrowser.LoadingStateChanged += _pageLoadedEventHandler;

            while (LoadingPage)
            {
                await Task.Delay(50); //if still crawling
            }
        }