Utilisez Shifter avec Puppeteer
Pilotez une vraie instance Chromium via les proxies résidentiels de Shifter en quelques minutes. Prise en charge native de --proxy-server, page.authenticate(), ciblage géographique par onglet et mise à l'échelle complète en cluster — aucun plugin supplémentaire requis.
Démarrage rapide
Installer
npm install puppeteer Utilisation de base
import puppeteer from "puppeteer";
const browser = await puppeteer.launch({
args: ["--proxy-server=http://p.shifter.io:443"],
headless: "new",
});
const page = await browser.newPage();
await page.authenticate({
username: "customer-USERNAME-country-us-sid-123ABC",
password: "PASSWORD",
});
await page.goto("https://ipinfo.io/json");
console.log(await page.evaluate(() => document.body.textContent));
// {"ip": "154.16.xxx.xxx", "city": "New York", "country": "US", ...}
await browser.close(); Fonctionnalités
Exemples
Proxy authentifié + session sticky
Épinglez une IP résidentielle pour toute la session du navigateur en ajoutant `sid-XXX` au nom d'utilisateur. Ajoutez `country-uk-city-london` pour le ciblage géographique et `ttl-300` pour conserver cette IP pendant 300 secondes.
import puppeteer from "puppeteer";
import { randomBytes } from "node:crypto";
const sid = randomBytes(4).toString("hex");
const browser = await puppeteer.launch({
args: [
"--proxy-server=http://p.shifter.io:443",
"--no-sandbox",
"--disable-blink-features=AutomationControlled",
],
headless: "new",
});
const page = await browser.newPage();
await page.authenticate({
username: `customer-USERNAME-country-uk-city-london-sid-${sid}-ttl-300`,
password: "PASSWORD",
});
await page.setUserAgent(
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
);
// Multi-step flow — every page load reuses the same residential IP.
await page.goto("https://example.co.uk/login", { waitUntil: "networkidle0" });
await page.type("#email", "user@example.com");
await page.type("#password", "secret");
await page.click('button[type="submit"]');
await page.waitForNavigation({ waitUntil: "networkidle0" });
await page.goto("https://example.co.uk/dashboard");
const html = await page.content();
console.log(html.length, "bytes from dashboard");
await browser.close(); Géociblage par onglet
Chaque nouvelle page obtient ses propres identifiants de proxy — laissez un onglet scraper un site américain pendant qu'un autre scrape un site japonais, le tout via un seul navigateur.
import puppeteer from "puppeteer";
const browser = await puppeteer.launch({
args: ["--proxy-server=http://p.shifter.io:443"],
headless: "new",
});
async function scrape(country: string, url: string) {
const page = await browser.newPage();
await page.authenticate({
username: `customer-USERNAME-country-${country}-sid-${country}-001`,
password: "PASSWORD",
});
await page.goto(url, { waitUntil: "domcontentloaded" });
const data = await page.evaluate(() => ({
title: document.title,
text: document.body.innerText.slice(0, 200),
}));
await page.close();
return { country, ...data };
}
const results = await Promise.all([
scrape("us", "https://www.example.com"),
scrape("jp", "https://www.example.jp"),
scrape("de", "https://www.example.de"),
scrape("br", "https://www.example.com.br"),
]);
console.log(results);
await browser.close(); Puppeteer Cluster (scraping parallèle)
Passez à des dizaines de pages en parallèle sans saturer la mémoire. Transmettez le proxy via puppeteerOptions et authentifiez-vous par page dans votre fonction de tâche.
import { Cluster } from "puppeteer-cluster";
const cluster = await Cluster.launch({
concurrency: Cluster.CONCURRENCY_PAGE,
maxConcurrency: 10,
puppeteerOptions: {
args: ["--proxy-server=http://p.shifter.io:443"],
headless: "new",
},
monitor: true,
});
await cluster.task(async ({ page, data: url }) => {
await page.authenticate({
username: `customer-USERNAME-country-us-sid-${url.replace(/\W+/g, "").slice(0, 8)}`,
password: "PASSWORD",
});
await page.goto(url, { waitUntil: "networkidle0" });
const title = await page.title();
const html = await page.content();
return { url, title, length: html.length };
});
const urls = [
"https://example.com/category/laptops",
"https://example.com/category/phones",
"https://example.com/category/tablets",
// ... hundreds more
];
const results = await Promise.all(urls.map((url) => cluster.execute(url)));
console.log(results);
await cluster.idle();
await cluster.close(); Mode furtif + blocage des ressources
Combinez Shifter avec le plugin stealth de puppeteer-extra et bloquez les images / polices / médias pour scraper 5 à 10 fois plus vite tout en évitant les indicateurs d'automatisation de Chrome.
import puppeteer from "puppeteer-extra";
import StealthPlugin from "puppeteer-extra-plugin-stealth";
puppeteer.use(StealthPlugin());
const browser = await puppeteer.launch({
args: [
"--proxy-server=http://p.shifter.io:443",
"--disable-blink-features=AutomationControlled",
],
headless: "new",
});
const page = await browser.newPage();
await page.authenticate({
username: "customer-USERNAME-country-us-city-newyork-sid-789GHI",
password: "PASSWORD",
});
// Block images, fonts, and media for faster page loads
await page.setRequestInterception(true);
page.on("request", (req) => {
const blocked = ["image", "font", "media", "stylesheet"];
blocked.includes(req.resourceType()) ? req.abort() : req.continue();
});
await page.goto("https://example.com", { waitUntil: "domcontentloaded" });
const products = await page.$$eval(".product", (els) =>
els.map((el) => ({
title: el.querySelector("h2")?.textContent?.trim(),
price: el.querySelector(".price")?.textContent?.trim(),
})),
);
console.log(products);
await browser.close(); Questions fréquentes Questions FAQ
Questions fréquentes sur l'utilisation de Shifter avec Puppeteer.
Pass --proxy-server=http://p.shifter.io:443 to the browser launch args, then call page.authenticate({ username, password }) on each page before navigating. The same proxy applies to every tab and the credentials handle the basic-auth challenge transparently.
Commencer à utiliser Shifter avec Puppeteer
Pilotez Chromium en mode headless via les 205M+ proxies résidentiels et ISP de Shifter. --proxy-server natif, ciblage géographique par onglet, sessions persistantes et prise en charge complète de Puppeteer-cluster.