Furry / 2captcha

A wrapper around the 2captcha api
71 stars 23 forks source link

pollingFrequency is only for the first call, the others calls only need to wait 5 seconds #9

Closed yunielrc closed 2 years ago

yunielrc commented 3 years ago

Hi, @Furry I can improve the code and send you a pull request

Furry commented 3 years ago

Could you elaborate a bit more on this? I'm not sure I understand what you mean.

yunielrc commented 3 years ago

Hi @Furry,

It's a waste of time to wait more than 5 seconds if the captcha isn't ready.

According to the 2captcha api documentation on https://2captcha.com/2captcha-api: The process of solving captchas with 2captcha is really easy and it's mostly the same for all types of captchas: .... Step 4. Submit a HTTP GET request to our API URL: http://2captcha.com/res.php to get the result. If captcha is already solved server will return the answer in format corresponding to the type of your captcha. By default answers are returned as plain text like: OK|Your answer. But answer can also be returned as JSON {"status":1,"request":"TEXT"} if json parameter is used.

LOOK AT HERE---> If captcha is not solved yet server will return CAPCHA_NOT_READY result. Repeat your request in 5 seconds. ...

NabiKAZ commented 2 years ago

About the issue raised and pull request. And this quote:

https://2captcha.com/2captcha-api: If captcha is not solved yet server will return CAPCHA_NOT_READY result. Repeat your request in 5 seconds.

In my opinion, these 5 seconds are just a suggestion and should be changed by the user. Otherwise 2captcha could control the request limit on the server and return the error to us, which is not the case.

This piece of code and number 5000ms is very strict:

case "CAPCHA_NOT_READY": return this.pollResponse(id, 5000);

https://github.com/Furry/2captcha/pull/10/files#diff-3923be146c30923916f3053402106966289a51bceaea0691ffdd4b30a9f0f376R144

I think it would be better to put the same pollingFreq instead and suggest it to the user in the documentation for 5 seconds. Imagine that the captcha is ready and you have to wait at least 5 seconds for no reason.

Even if you do not have a plan for this change, it is better to delete this parameter altogether, because at the moment, the amount of interrupt we want to use only once at the beginning of the request is useless and also misleads the user.

Furry commented 2 years ago

Thanks for bringing it to my attention, I'll take a look and fix this later today after my classes!

NabiKAZ commented 2 years ago

seem you closed without review, maybe forgotten :)

Furry commented 2 years ago

I blame the 'close with comment' button

Furry commented 2 years ago

I've manually reverted the changes in https://github.com/Furry/2captcha/pull/10/files#diff-3923be146c30923916f3053402106966289a51bceaea0691ffdd4b30a9f0f376R144, substituting the previous 5000ms delay with this.pollingFrequency 50743ac

NabiKAZ commented 2 years ago

It's better, Thanks.