Node.js SDK
Node.js SDK
Section titled “Node.js SDK”HydraSkill 公式の Node.js SDK。
インストール
Section titled “インストール”npm install hydraskillクイックスタート
Section titled “クイックスタート”import { 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);