Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SolveCaptchaAsync is throwing an error #55

Open
AdamB2023 opened this issue Jul 17, 2023 · 2 comments
Open

SolveCaptchaAsync is throwing an error #55

AdamB2023 opened this issue Jul 17, 2023 · 2 comments

Comments

@AdamB2023
Copy link

AdamB2023 commented Jul 17, 2023

var browser = await new PuppeteerExtra().Use(recaptchaPlugin).LaunchAsync(new LaunchOptions()
{
    Headless = false
});

 var page = await browser.NewPageAsync();
 await page.GoToAsync("https://patrickhlauke.github.io/recaptcha/");
 await recaptchaPlugin.SolveCaptchaAsync(page).ConfigureAwait(false);

Error:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=PuppeteerExtraSharp
  StackTrace:
   at PuppeteerExtraSharp.Plugins.Recaptcha.Provider.AntiCaptcha.AntiCaptchaApi.<>c.<PendingForResult>b__5_0(RestResponse`1 response)
   at PuppeteerExtraSharp.Plugins.Recaptcha.RestClient.PollingBuilder`1.<ActivatePollingAsync>d__7.MoveNext()
   at PuppeteerExtraSharp.Plugins.Recaptcha.Provider.AntiCaptcha.AntiCaptchaApi.<PendingForResult>d__5.MoveNext()
   at PuppeteerExtraSharp.Plugins.Recaptcha.Provider.AntiCaptcha.AntiCaptcha.<GetSolution>d__3.MoveNext()
   at PuppeteerExtraSharp.Plugins.Recaptcha.Recaptcha.<GetSolutionAsync>d__5.MoveNext()
   at PuppeteerExtraSharp.Plugins.Recaptcha.Recaptcha.<Solve>d__3.MoveNext()
   at PuppeteerExtraSharp.Plugins.Recaptcha.RecaptchaPlugin.<SolveCaptchaAsync>d__2.MoveNext()
   at Program.<Main>d__0.MoveNext() in C:\Users\_\Documents\Visual Studio 2022\Projects\_\_\Program.cs:line 32

  This exception was originally thrown at this call stack:
    [External Code]
    Program.Main(string[]) in Program.cs
@olegfridman
Copy link

olegfridman commented Aug 16, 2023

The issue is in the TaskResultModel. "cost" is declared as a string but according to Anti Captcha's docs, it's a double. Commenting out all of the unused properties (cost, ip, createTime, endTime, solveCount) fixes the issue.

public class TaskResultModel    {
    public int errorId { get; set; } 
    public string status { get; set; } 
    public Solution solution { get; set; } 
    //public double cost { get; set; } 
    //public string ip { get; set; } 
    //public int createTime { get; set; } 
    //public int endTime { get; set; } 
    //public string solveCount { get; set; } 
}

@trevorjdaniel-claimit
Copy link

i believe TaskResultModel should now look like this:

`public class TaskResultModel
{
public int errorId { get; set; }
public string status { get; set; }
public Solution solution { get; set; }
public string cost { get; set; }
public string ip { get; set; }
public int createTime { get; set; }
public int endTime { get; set; }
public int solveCount { get; set; }
}

public class Solution
{
public string gRecaptchaResponse { get; set; }
public Cookies cookies { get; set; }
}

public class Cookies
{
public string empty { get; set; }
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants