
⚙️ 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 Imperva without proxy
Here's a Node.JS sample script to accomplish the task:
const axios = require('axios');
const PAGE_URL = "Your page URL"; // Replace with your Website
const REESE_SCRIPT_URL = "Your Reesee Script Url"; // Replace with your reese script that contains the js
const CLIENT_KEY = "Your Capsolver Key"; // Replace with your CAPSOLVER API Key
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 solveImperva(pageURL, reeseScriptUrl) {
const taskPayload = {
type: "AntiImpervaTaskProxyLess",
websiteURL: pageURL,
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
utmvc: true,
reese84: true,
reeseScriptUrl: reeseScriptUrl
};
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 solveImperva(PAGE_URL, REESE_SCRIPT_URL );
console.log(`Received reese84 cookie: ${response.solution.token}`);
}
catch (error) {
console.error(`Error: ${error}`);
}
}
main();
👨💻 Node.JS Code for solve Imperva with proxy
Here's a Node.JS sample script to accomplish the task:
const axios = require('axios');
const PAGE_URL = "Your page URL"; // Replace with your Website
const REESE_SCRIPT_URL = "Your Reesee Script Url"; // Replace with your reese script that contains the js
const CLIENT_KEY = "Your Capsolver Key"; // Replace with your CAPSOLVER API Key
const PROXY = "https://username:password@host:port"; // Replace with your proxy information
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 solveImperva(pageURL, reeseScriptUrl) {
const taskPayload = {
type: "AntiImpervaTask",
websiteURL: pageURL,
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
utmvc: true,
reese84: true,
reeseScriptUrl: reeseScriptUrl,
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 solveImperva(PAGE_URL, REESE_SCRIPT_URL );
console.log(`Received reese84 cookie: ${response.solution.token}`);
}
catch (error) {
console.error(`Error: ${error}`);
}
}
main();
⚠️ Change these variables
- PROXY: Change to your proxy, only if you use AntiImpervaTask.
- 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
- REESE_SCRIPT_URL: Replace with the reese script url that contains the js