Utilisez Shifter avec Playwright
Faites tourner Chromium, Firefox et WebKit via les proxies résidentiels et ISP de Shifter — identifiants intégrés, aucune extension sidecar requise. Support proxy de premier ordre pour Node, Python, Java et .NET.
Démarrage rapide
Installer
npm install playwright Utilisation de base
import { chromium } from "playwright";
const browser = await chromium.launch({
proxy: {
server: "http://p.shifter.io:443",
username: "customer-USERNAME-country-us-sid-123ABC",
password: "PASSWORD",
},
});
const page = await browser.newPage();
await page.goto("https://ipinfo.io/json");
console.log(await page.textContent("body"));
// {"ip": "154.16.xxx.xxx", "city": "New York", "country": "US", ...}
await browser.close(); Fonctionnalités
Exemples
Ciblage géographique par contexte (un navigateur, plusieurs régions)
Chaque contexte de navigateur peut avoir son propre proxy. Lancez un contexte américain, un contexte britannique et un contexte japonais dans une seule instance de navigateur — la fonctionnalité phare de Playwright pour le scraping localisé en parallèle.
import { chromium } from "playwright";
const browser = await chromium.launch();
async function makeContext(country: string, sid: string) {
return browser.newContext({
proxy: {
server: "http://p.shifter.io:443",
username: `customer-USERNAME-country-${country}-sid-${sid}`,
password: "PASSWORD",
},
userAgent:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
});
}
const [us, uk, jp] = await Promise.all([
makeContext("us", "us-001"),
makeContext("uk", "uk-001"),
makeContext("jp", "jp-001"),
]);
const [usPage, ukPage, jpPage] = await Promise.all([
us.newPage(),
uk.newPage(),
jp.newPage(),
]);
await Promise.all([
usPage.goto("https://www.example.com"),
ukPage.goto("https://www.example.co.uk"),
jpPage.goto("https://www.example.jp"),
]);
console.log({
us: await usPage.title(),
uk: await ukPage.title(),
jp: await jpPage.title(),
});
await browser.close(); Multi-navigateur (Chromium / Firefox / WebKit)
La même configuration de proxy fonctionne sur les trois moteurs. Utile pour le scraping multi-navigateur ou pour choisir le moteur le moins susceptible de déclencher la détection de bots sur une cible donnée.
import { chromium, firefox, webkit, type BrowserType } from "playwright";
const proxy = {
server: "http://p.shifter.io:443",
username: "customer-USERNAME-country-de-city-berlin-sid-456DEF",
password: "PASSWORD",
};
async function visit(engine: BrowserType, label: string) {
const browser = await engine.launch({ proxy });
const page = await browser.newPage();
await page.goto("https://example.de");
const title = await page.title();
await browser.close();
return { label, title };
}
const results = await Promise.all([
visit(chromium, "chromium"),
visit(firefox, "firefox"),
visit(webkit, "webkit"),
]);
console.log(results); Suite de tests Playwright
Configurez Shifter une seule fois dans playwright.config.ts afin que chaque test passe par le proxy. Utilisez des variables d'environnement pour les identifiants afin de ne pas les valider dans le code source.
// playwright.config.ts
import { defineConfig } from "@playwright/test";
export default defineConfig({
testDir: "./tests",
workers: 4,
use: {
proxy: {
server: "http://p.shifter.io:443",
username: process.env.SHIFTER_USER!, // e.g. customer-USERNAME-country-us-sid-test
password: process.env.SHIFTER_PASS!,
},
userAgent:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
viewport: { width: 1920, height: 1080 },
ignoreHTTPSErrors: false,
},
});
// tests/products.spec.ts
import { test, expect } from "@playwright/test";
test("US homepage renders", async ({ page }) => {
await page.goto("https://example.com");
await expect(page.getByRole("heading", { level: 1 })).toBeVisible();
});
test("Product page parses", async ({ page }) => {
await page.goto("https://example.com/products/123");
const price = await page.locator(".price").textContent();
expect(price).toMatch(/^\$\d+/);
}); Python : chromium.launch avec session persistante
Playwright est identique dans tous les langages. La même configuration proxy sous forme de dictionnaire en Python — et le reste de l'API reflète la version Node.
# pip install playwright
# playwright install chromium
import asyncio
import secrets
from playwright.async_api import async_playwright
async def main():
sid = secrets.token_hex(4)
async with async_playwright() as p:
browser = await p.chromium.launch(
proxy={
"server": "http://p.shifter.io:443",
"username": f"customer-USERNAME-country-fr-city-paris-sid-{sid}-ttl-300",
"password": "PASSWORD",
}
)
context = await browser.new_context(
user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36",
)
page = await context.new_page()
# Multi-step flow — same residential IP across every navigation.
await page.goto("https://example.fr/login", wait_until="networkidle")
await page.fill("#email", "user@example.com")
await page.fill("#password", "secret")
await page.click("button[type=submit]")
await page.wait_for_url("**/dashboard")
rows = await page.locator(".order-row").all_text_contents()
print(f"Found {len(rows)} orders")
await browser.close()
asyncio.run(main()) Questions fréquentes Questions FAQ
Questions fréquentes sur l'utilisation de Shifter avec Playwright.
Passez un champ `proxy` dans les options de lancement du navigateur avec `server`, `username` et `password`. La même structure s'applique à Chromium, Firefox et WebKit. Les identifiants sont passés en ligne — aucune extension requise, et cela fonctionne en mode headless par défaut.
Commencer à utiliser Shifter avec Playwright
Pilotez Chromium, Firefox et WebKit via les 205M+ proxies résidentiels et ISP de Shifter — identifiants intégrés directement, aucune extension requise. Compatible avec Node, Python, Java et .NET.