Contact Us
If you still have questions or prefer to get help directly from an agent, please submit a request.
Popular topics: Multilogin X, Multilogin 6,
-
Retrieving the token Using the automation token in a workspace Retrieving profile, folder, and workspace IDs Retrieving the user ID Selenium automation example Playwright automation example Puppeteer automation example Logging in to Multilogin automatically Setting up automatic cookie collection Auto-launching the agent Exporting proxy details from profiles Converting external proxy lists into API-ready JSON files Automation FAQConnecting the agent Testing a proxy Saving browser data Using a VPS/VPN to resolve connection issues Using Multilogin on macOS Investigating speed issues Can't start Multilogin Can't launch profile or connect to proxy Error: Failed to get profile data Stopping the agent from auto-sending log files Handling ban issues Issue: Profile is locked Troubleshooting FAQ
-
Error: Failed to get IP data: can't connect through proxy Error: Javax.crypto.badpaddingexception: pad block corrupted Status: Update in progress...Loading (1) of 2 components Error: Fingerprint composition failed Connection error due to non-Latin characters in Windows username Error: Mimic/Stealthfox executable is not found Multilogin 6 browser profile shows "Error" in status Can't launch a profile in Multilogin 6 JavaScript error when switching to dark mode in Multilogin 6 Common errors and solutions in Multilogin 6
Puppeteer automation example
Written by Villa Wu
Updated on December 12th, 2024
Table of contents
Puppeteer is a Node.js library developed by Google that offers a high-level API to control Chromium through the DevTools Protocol. You can use Puppeteer to automate tasks in Mimic browser profiles within Multilogin. In this article, we'll show you how to get started with an example.
You can only automate Mimic browser profiles using Puppeteer. Stealthfox, which is based on Mozilla Firefox, is not supported by it.
Before you start
- Download Node.js from the official website and install it
- Ensure Node.js and npm (Node Package Manager) are installed correctly:
node -v
npm -v
- Create a project directory, then run this command to initialize a new Node.js project and create a
package.json
file:
npm init -y
- Install Puppeteer as a dependency for your project:
npm install puppeteer
- Install Axios and MD5 library:
npm install axios
npm install md5
- Insert your values into the below variables in the script:
- Replace
https://multilogin.com/
with the website you need in the following line:
await page.goto("https://multilogin.com/");
Running the script
- Make sure the agent is connected, as it makes profile launching possible
- Make sure Puppeteer is compatible with the current Mimic core version – check the release notes for Puppeteer and Mimic
- Run the
.js
file with your automation code
Script example
const puppeteer = require('puppeteer');
const md5 = require('md5');
const axios = require('axios');
const HEADERS = {
"Content-Type": "application/json",
"Accept": "application/json",
};
const acc_info = {
// Insert your account information in both variables below
"email": "",
"password": md5("")
};
async function get_token() {
const signIn_URL = "https://api.multilogin.com/user/signin";
try {
const response = await axios.post(signIn_URL, acc_info, {
headers: HEADERS
});
return response.data.data.token;
} catch (error) {
console.log(error.message);
console.log("Response data:", error.response.data);
return false;
}
};
// Insert the Folder ID and the Profile ID below
const folder_id = "";
const profile_id = "";
async function start_browserProfile() {
const token = await get_token();
if (!token) return;
// Update HEADERS with bearer token retrived from the get_token function
HEADERS.Authorization = 'Bearer ' + token;
// Launch a profile defining "Puppeteer" as automation type
const profileLaunch_URL = `https://launcher.mlx.yt:45001/api/v2/profile/f/${folder_id}/p/${profile_id}/start?automation_type=puppeteer&headless_mode=false`;
try {
const response = await axios.get(profileLaunch_URL, {
headers: HEADERS
});
const browserURL = `http://127.0.0.1:${response.data.data.port}`;
// if you prefer to connect with browserWSEndpoint, try to get the webSocketDebuggerUrl by following request
// const {data : {webSocketDebuggerUrl}} = await axios.get(`${browserURL}/json/version`)
const browser = await puppeteer.connect({
browserURL: browserURL,
timeout: 10000
});
const page = await browser.newPage();
await page.goto("https://multilogin.com/");
await page.screenshot({
path: "example.png"
})
await page.close();
} catch (error) {
console.log("Error:", error.message);
if (error.response) {
console.log("Response data:", error.response.data);
}
}
};
start_browserProfile();