Created
June 15, 2022 23:11
-
-
Save Octagon-simon/2dac24eed3189b090ccce2dcb896e9a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function solveCaptcha(siteKey, pageUrl){ | |
| const apiKey = "YOUR_API_KEY"; | |
| //make a GET request to 2captcha | |
| fetch(`https://2captcha.com/in.php?key=${apiKey} | |
| &method=userrecaptcha&googlekey=${siteKey}&pageurl=${pageUrl}&json=1`) | |
| .then(response => response.json()) | |
| .then(data => { | |
| //check if there's an error | |
| if(!data.status){ | |
| //print out error | |
| logErr('Error:', (data.error_text !== undefined) ? data.error_text : data.request); | |
| }else{ | |
| setTimeout(function(captchaId = data.request){ | |
| //make another call with the ID to get the captcha's status | |
| fetch(`https://2captcha.com/res.php?key=${apiKey}&action=get&id=${captchaId}&json=1`) | |
| .then(response => response.json()) | |
| .then(data => { | |
| if(!data.status){ | |
| //print out error | |
| logErr('Error:', (data.error_text !== undefined) ? data.error_text : data.request); | |
| }else{ | |
| //do something else with the data | |
| } | |
| }) | |
| .catch(error => { | |
| logErr('Error:', error); | |
| }); | |
| }, 20000); | |
| } | |
| }) | |
| .catch(error => { | |
| logErr('Error:', error); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment