Advanced Guide

ブラウザ自動化をマスターする

Puppeteer、Playwright、Seleniumを使用したNox Coreの自動化完全ガイド。本番環境対応のコード例とベストプラクティス。

クイックスタート

5分で起動

コード例

コピーして使えるスニペット

RPAエンジン

ノーコード自動化

Code Examples

Puppeteer + Chrome DevTools Protocol

Connect to Nox Core via Chrome DevTools Protocol for full browser control.

基本設定
// 1. Launch Nox Core with remote debugging
// Add flag: --remote-debugging-port=9222

const puppeteer = require('puppeteer-core');

const browser = await puppeteer.connect({
  browserWSEndpoint: 'ws://localhost:9222',
  defaultViewport: null
});

const page = await browser.newPage();
await page.goto('https://example.com');
高度な機能
// Advanced profile management
const profileId = 'your-profile-id';

// Get all available targets
const targets = await browser.targets();
const pageTarget = targets.find(t => t.type() === 'page');

// Execute CDP commands
const client = await page.target().createCDPSession();

// Set custom user agent
await client.send('Network.setUserAgentOverride', {
  userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
});

// Block specific resources
await client.send('Network.setBlockedURLs', {
  urls: ['*.analytics.com', '*.tracking.js']
});
自動化パターン
// Automation best practices
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));

// Human-like typing
async function humanType(page, selector, text) {
  for (const char of text) {
    await page.type(selector, char, { delay: Math.random() * 100 + 50 });
  }
}

// Random mouse movements
async function randomMove(page) {
  await page.mouse.move(
    Math.random() * 800 + 100,
    Math.random() * 600 + 100
  );
}

// Use in your script
await randomMove(page);
await humanType(page, '#username', 'john_doe');
await delay(Math.random() * 500 + 200);
await humanType(page, '#password', 'secret123');

ベストプラクティス

検出を回避

  • アクション間に現実的な遅延を使用(200-1000ms)
  • マウス移動とクリック位置をランダム化
  • ビューポートサイズとユーザーエージェントを変更
  • セッション間でCookieとストレージをクリア

パフォーマンス

  • 可能な場合はブラウザインスタンスを再利用
  • パフォーマンス向上のためヘッドレスモードを使用
  • 不要なリソースをブロック
  • コネクションプーリングを実装

プロキシ管理

  • 10-20リクエストごとにプロキシをローテーション
  • プロキシの場所をタイムゾーンと一致させる
  • 使用前にプロキシの品質をテスト
  • 機密性の高いサイトには住宅/ISPプロキシを使用

エラー処理

  • 指数バックオフでリトライロジックを実装
  • 失敗時にスクリーンショットを取得
  • デバッグ用にすべてのアクションをログ
  • CAPTCHAを適切に処理

RPAエンジンの例

ログイン自動化

2FAサポートでログインフローを自動化

// Nox Core RPA - Login Flow
{
  "steps": [
    { "action": "navigate", "url": "https://example.com/login" },
    { "action": "wait", "selector": "#username", "timeout": 5000 },
    { "action": "type", "selector": "#username", "value": "{{USERNAME}}" },
    { "action": "type", "selector": "#password", "value": "{{PASSWORD}}" },
    { "action": "click", "selector": "#login-btn" },
    { "action": "wait", "selector": ".dashboard", "timeout": 10000 },
    { "action": "extract", "selector": ".user-name", "variable": "loggedUser" }
  ]
}

データ抽出

複数のページからデータを抽出

// Nox Core RPA - Data Extraction
{
  "steps": [
    { "action": "navigate", "url": "{{PRODUCT_URL}}" },
    { "action": "wait", "selector": ".product-title" },
    { "action": "extract", "selector": ".product-title", "variable": "title" },
    { "action": "extract", "selector": ".price", "variable": "price" },
    { "action": "extract", "selector": ".availability", "variable": "stock" },
    { "action": "screenshot", "name": "product_{{timestamp}}" },
    { "action": "webhook", "url": "{{API_ENDPOINT}}", "data": ["title", "price", "stock"] }
  ]
}

フォーム送信

複雑なフォーム送信を自動化

// Nox Core RPA - Form Submission
{
  "steps": [
    { "action": "navigate", "url": "https://example.com/form" },
    { "action": "select", "selector": "#country", "value": "{{COUNTRY}}" },
    { "action": "type", "selector": "#fullname", "value": "{{FULLNAME}}" },
    { "action": "type", "selector": "#email", "value": "{{EMAIL}}" },
    { "action": "click", "selector": "#terms-checkbox" },
    { "action": "click", "selector": "#submit-btn" },
    { "action": "wait", "selector": ".success-message", "timeout": 15000 },
    { "action": "condition", "if": ".error", "then": [{ "action": "log", "message": "Submission failed" }] }
  ]
}

重要な通知

自動化時は常にWebサイトの利用規約を遵守してください。自動化を責任を持って使用し、現地の法律と規制を遵守してください。

追加リソース

自動化の準備はできましたか?

Nox Coreライセンスを取得して、今日から強力な自動化ワークフローを構築しましょう。

始める