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

Set captcha provider and options with json request #38

Open
xfouloux opened this issue Dec 16, 2020 · 3 comments
Open

Set captcha provider and options with json request #38

xfouloux opened this issue Dec 16, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@xfouloux
Copy link
Collaborator

xfouloux commented Dec 16, 2020

Given we can implement many captcha solver, having the possibility to choose with which solver you want to solve the request you're asking it to solve would be a great addition.

curl -L -X POST 'http://flaresolverr:8191/v1' \
-H 'Content-Type: application/json' \
--data-raw '{
  "cmd": "request.get",
  "url":"https://patrickhlauke.github.io/recaptcha/",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleW...",
  "maxTimeout": 60000,
  "solver-provider": { 
    "name": "xxxxxx", 
    "options": {
      "apikey": "yyyyy",
      "otheroptionoptionnal": "zzzzz"
     }
  }
  "headers": {
    "X-Test": "Testing 123..."
  }
}'

setting solver-provider in the json with the name of the actual captcha solver existing, overriding the ENV var if defined and defining optional options, like api key and possibly other stuff

EXAMPLE

My first example would be in jackett to integrate a menu with captcha providers for flaresolverr (restricting jackett to flaresolverr ? or having a SELECT Menu with Solver APP like Flaresolverr) and then configuring said providers, the need to provide providers capabilities would then be great between app and solver to automagically propose settings (best case scenario)

Easy case, would just be type your provider name, and APIKEY in an input and that's it to POC, or basic implementation

Then Jackett could try 1st provider, if no result move to do res with second provider, etc.. etc...
You could in jackett set your provider priorities too

Thanks.

@xfouloux
Copy link
Collaborator Author

If I understand the code properly

JSON body text is inserted in the variable ctx of type RequestContext in the object req

So in order to use this kind of options, i would only have to modify something like that

file captcha/index.ts

import ctx from "../index.ts";

export default (): Solver => {
  if (ctx.req.hasOwnProperty(solver-provider)){
    const method = ctx.req.solver-provider.name
  }else{
    const method = process.env.CAPTCHA_SOLVER
 }

File captcha/anticaptcha.ts

import ctx from "./index.ts"; 
# Can i import ctx from captcha/index.ts or do i need to import it from the ../index.ts ???

const ANTI_CAPTCHA_APIKEY: string = ctx.req.solver-provider.options.apikey || process.env.ANTI_CAPTCHA_APIKEY

i am on the right track or i'm completely not understanding typescript ^^ ?

@abeloin abeloin added the enhancement New feature or request label Dec 16, 2020
@ngosang
Copy link
Member

ngosang commented Dec 16, 2020

I'm not opposed but I think this logic can be handled by FlareSolverr. I like to think that FlareSolverr is a black box to which you send a URL and it returns cookies that work in any application. Jackett doesn't need to know what logic to apply.

In the long term I think FlareSolverr should have a configuration file instead of environment variables. It's more flexible and it will allow to configure several captcha solvers with priorities. You can configure rules, for example a list of domains will be solved with this solver or try all solvers until one of them works...

That said, we have many open issues. For me the priority is to help Jackett users to configure FlareSolverr and improve the documentation (I am thinking of writing articles in the wiki so as not to fill the readme).

A couple of tips from someone who's been programming for a long time. Don't try to solve all the problems at once. Choose one of the anti-captcha and try to implement it until it is finished. To do a test you don't need to have the configuration, just hardcode the apikey and other configurations in the code and try to make it work. When you have something that works more or less, you can open a PR and we will help you with comments about the code. Typescript is just a Javascript with types, both languages quite ugly. Install a good IDE with Typescript plugins like Visual Studio Code, it will help.

@xfouloux
Copy link
Collaborator Author

Indeed you approach seems better =) !
I'll focus on doing the anti captcha provider for now and we will see that in a near future ^^
Thanks

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

No branches or pull requests

3 participants