Node.js SDK
Node.js SDK
Section titled “Node.js SDK”HydraSkill 官方 Node.js SDK。
npm install hydraskillimport { ProxyClient } from 'hydraskill';
const client = new ProxyClient({ apiKey: process.env.HYDRASKILL_API_KEY });
const proxy = await client.getProxy({ target: 'amazon.com', sessionLock: true, country: 'US',});
// 配合 fetch 使用const response = await fetch('https://amazon.com', { agent: proxy.toAgent(),});
// 释放await proxy.release();配合 Puppeteer
Section titled “配合 Puppeteer”import puppeteer from 'puppeteer';import { ProxyClient } from 'hydraskill';
const client = new ProxyClient();const proxy = await client.getProxy({ target: 'amazon.com' });
const browser = await puppeteer.launch({ args: [`--proxy-server=${proxy.toProxyUrl()}`],});
const page = await browser.newPage();await page.authenticate({ username: proxy.username, password: proxy.password });await page.goto('https://amazon.com');TypeScript
Section titled “TypeScript”完整的 TypeScript 支持,并导出类型:
import { ProxyClient, Proxy, ProxyOptions } from 'hydraskill';
const options: ProxyOptions = { target: 'amazon.com', sessionLock: true,};
const proxy: Proxy = await client.getProxy(options);