Blog
How to solve reCaptcha v3 with Node.JS

How to solve reCaptcha v3 with Node.JS

Logo of Capsolver

CapSolver Blogger

How to use capsolver

15-Sep-2023

Bypass reCaptcha v3 with Javascript, reCaptcha v3 js solver

📁 Prerequisites

  • A working proxy
  • Node.JS Installed
  • Capsolver API key

🌿 Step 1: Install Necessary Packages

Execute the following commands to install the required packages:

npm install axios

⚡ Step 2: Node.JS Code for bypass reCaptcha v3 and get 0.7-0.9 score

Here's a Node.JS sample script to accomplish the task:

const PROXY = "http://username:password@host:port";
const PAGE_URL = "https://antcpt.com/score_detector";
const PAGE_KEY = "6LcR_okUAAAAAPYrPe-HK_0RULO1aZM15ENyM-Mf";
const PAGE_ACTION = "homepage";
const CAPSOLVER_KEY = "YourKey"

async function createTask(url, key, pageAction) {
    try {
      // Define the API endpoint and payload as per the service documentation.
      const apiUrl = "https://api.capsolver.com/createTask";
      const payload = {
        clientKey: CAPSOLVER_KEY,
        task: {
          type: "ReCaptchaV3Task",
          websiteURL: url,
          websiteKey: key,
          pageAction: pageAction,
          proxy: PROXY,
        }
      };
      const headers = {
        'Content-Type': 'application/json',
      };
      const response = await axios.post(apiUrl, payload, { headers });
      return response.data.taskId;
  
    } catch (error) {
      console.error("Error creating CAPTCHA task: ", error);
      throw error;
    }
  }
  
  async function getTaskResult(taskId) {
    try {
      const apiUrl = "https://api.capsolver.com/getTaskResult";
      const payload = {
        clientKey: CAPSOLVER_KEY,
        taskId: taskId,
      };
      const headers = {
        'Content-Type': 'application/json',
      };
      let result;
      do {
        const response = await axios.post(apiUrl, payload, { headers });
        result = response.data;
        if (result.status === "ready") {
          return result.solution;
        }
        await new Promise(resolve => setTimeout(resolve, 5000)); // wait 5 seconds before retrying
      } while (true);
  
    } catch (error) {
      console.error("Error getting CAPTCHA result: ", error);
      throw error;
    }
  }
  

function setSessionHeaders() {
  return {
    'cache-control': 'max-age=0',
    'sec-ch-ua': '"Not/A)Brand";v="99", "Google Chrome";v="107", "Chromium";v="107"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': 'Windows',
    'upgrade-insecure-requests': '1',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36',
    'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
    'sec-fetch-site': 'same-origin',
    'sec-fetch-mode': 'navigate',
    'sec-fetch-user': '?1',
    'sec-fetch-dest': 'document',
    'accept-encoding': 'gzip, deflate',
    'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,en-US;q=0.7',
  };
}

async function main() {
    
    const headers = setSessionHeaders();
    console.log("Creating CAPTCHA task...");
    const taskId = await createTask(PAGE_URL, PAGE_KEY, PAGE_ACTION);
    console.log(`Task ID: ${taskId}`);

    console.log("Retrieving CAPTCHA result...");
    const solution = await getTaskResult(taskId);
    const token = solution.gRecaptchaResponse;
    console.log(`Token Solution ${token}`);


  const res = await axios.post("https://antcpt.com/score_detector/verify.php", { "g-recaptcha-response": token }, { headers });
  const response = res.data;
  console.log(`Score: ${response.score}`);
}

main().catch(err => {
  console.error(err);
});

🛡️ Fields to Update

  • PROXY: Update with your proxy details. The format should be http://username:password@ip:port.
  • capsolver.api_key: Obtain your API key from the Capsolver Dashboard.
  • PAGE_URL: Replace with the URL of the website for which you wish to bypass the reCaptcha v3.
  • PAGE_KEY: Update with the specific key of the site with recaptcha.
  • PAGE_ACTION: Replace with the pageAction of the page. You can read this blog

👀 More information

More

How to Identify the Version of reCaptcha
How to Identify the Version of reCaptcha

In this article, we will show you how to identify what reCaptcha version is being used.

reCAPTCHA

19-Sep-2023

Bypassing reCaptcha V2 with Python
How to solve reCaptcha v2 with Python

In this article, we will show you how to solve reCaptcha v2 with Python

reCAPTCHA

19-Sep-2023

How to solve reCaptcha v3 with Node.JS
How to solve reCaptcha v3 with Node.JS

In this article, we will show you how to solve reCaptcha v3 with Node.JS

reCAPTCHA

15-Sep-2023

How to solve reCaptcha v3 with Python
How to solve reCaptcha v3 with Python

In this article, we will show you how to solve reCaptcha v3 with Python.

reCAPTCHA

15-Sep-2023

Bypass reCaptcha v3
Bypass reCaptcha v3

In the guide that follows, we aim to unravel the seemingly complex procedure of seamlessly navigating through reCaptcha v3 and achieving a score indicative of human interaction, using the cutting-edge tool, CapSolver. For those unfamiliar, reCaptcha v3 is a contemporary security mechanism offered by Google, engineered to shield websites from bot activities without requiring user input. In contrast to its previous versions, reCaptcha v3 computes and delivers a score that predicts if the engagement is human or bot-driven, rather than posing a challenge to be solved. As user-friendly and efficient as this tool is, it may inadvertently create obstacles for genuine users, interfering with their seamless digital navigation. This is where CapSolver steps in. CapSolver is an advanced tool devised to assist users in smoothly traversing through reCaptcha v3. It's specially designed to interact with reCaptcha in a manner that simulates human behavior, hence achieving a score akin to a human user. By having CapSolver on hand, you can guarantee a more streamlined online journey, devoid of the typical CAPTCHA-related delays or disruptions. Throughout this guide, we'll walk you through each step, transforming complex tech terminology into easily digestible information. Our goal is to deliver a comprehensive understanding of how to employ CapSolver effectively, enabling you to navigate through reCaptcha v3 with relative simplicity. We want to make it clear that this guide is meant to support genuine users in their journey through reCaptcha v3, and does not endorse any unethical activities or attempts to compromise website security. Whether you're a professional exploring the digital world or an everyday internet user, gaining a solid understanding of reCaptcha v3 and mastering tools like CapSolver can significantly elevate your online navigation skills. Join us as we delve deeper into this intriguing subject, arming you with invaluable expertise for your digital odyssey.

reCAPTCHA

29-Aug-2023

How to find the callback function of reCaptcha
How to find the callback function of reCaptcha

Finding the callback of a reCAPTCHA involves identifying the JavaScript function that's executed after the reCAPTCHA is successfully solved. Here's a brief preview of the steps you might take

reCAPTCHA

28-Aug-2023