
##⚙️ Prerequisites
- Proxy (Optional)
- Node.JS installed
- Capsolver API key
🤖 Step 1: Install Necessary Packages
Execute the following commands to install the required packages:
npm install axios
👨💻 Node.JS Code for solve FunCaptcha without proxy
Here's a Node.JS sample script to accomplish the task:
const axios = require('axios');
const PAGE_URL = "Page URL with FunCaptcha"; // Replace with your Website
const CLIENT_KEY = "Your Capsolver Key"; // Replace with your CAPSOLVER API Key
const SITE_KEY = "Public Site Key" // Replace with the site key that the captcha have
async function createTask(payload) {
try {
const res = await axios.post('https://api.capsolver.com/createTask', {
clientKey: CLIENT_KEY,
task: payload
});
return res.data;
} catch (error) {
console.error(error);
}
}
async function getTaskResult(taskId) {
try {
success = false;
while(success == false){
await sleep(1000);
console.log("Getting task result for task ID: " + taskId);
const res = await axios.post('https://api.capsolver.com/getTaskResult', {
clientKey: CLIENT_KEY,
taskId: taskId
});
if( res.data.status == "ready") {
success = true;
console.log(res.data)
return res.data;
}
}
} catch (error) {
console.error(error);
return null;
}
}
async function solveFuncaptcha(pageURL, siteKey, data = "") {
const taskPayload = {
type: "FunCaptchaTaskProxyless",
websiteURL: pageURL,
websitePublicKey: siteKey,
data: data,
};
const taskData = await createTask(taskPayload);
return await getTaskResult(taskData.taskId);
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function main() {
try {
const response = await solveFuncaptcha(PAGE_URL, SITE_KEY );
console.log(`Received FunCaptcha Token: ${response.solution.token}`);
}
catch (error) {
console.error(`Error: ${error}`);
}
}
main();
👨💻Node.JS Code for solve FunCaptcha with proxy
Here's a Node.JS sample script to accomplish the task:
const axios = require('axios');
const PAGE_URL = "Page URL with FunCaptcha"; // Replace with your Website
const CLIENT_KEY = "Your Capsolver Key"; // Replace with your CAPSOLVER API Key
const SITE_KEY = "Public Site Key" // Replace with the site key that the captcha have
const PROXY = "http://username:password@host:port" // Replace with the site key that the captcha have
async function createTask(payload) {
try {
const res = await axios.post('https://api.capsolver.com/createTask', {
clientKey: CLIENT_KEY,
task: payload
});
return res.data;
} catch (error) {
console.error(error);
}
}
async function getTaskResult(taskId) {
try {
success = false;
while(success == false){
await sleep(1000);
console.log("Getting task result for task ID: " + taskId);
const res = await axios.post('https://api.capsolver.com/getTaskResult', {
clientKey: CLIENT_KEY,
taskId: taskId
});
if( res.data.status == "ready") {
success = true;
console.log(res.data)
return res.data;
}
}
} catch (error) {
console.error(error);
return null;
}
}
async function solveFuncaptcha(pageURL, siteKey, data = "") {
const taskPayload = {
type: "FunCaptchaTask",
websiteURL: pageURL,
websitePublicKey: siteKey,
data: data,
proxy: PROXY
};
const taskData = await createTask(taskPayload);
return await getTaskResult(taskData.taskId);
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function main() {
try {
const response = await solveFuncaptcha(PAGE_URL, SITE_KEY );
console.log(`Received FunCaptcha Token: ${response.solution.token}`);
}
catch (error) {
console.error(`Error: ${error}`);
}
}
main();
⚠️ Change these variables
- PROXY: Change to your proxy, only if you use FuncaptchaTask.
- CLIENT_KEY: Obtain your API key from the Capsolver Dashboard.
- PAGE_URL: Replace with the URL of the website for which you wish to solve FunCaptcha
- SITE_KEY: Replace with the site key of the website for which you wish to solve FunCaptcha