Replicate web pages with all their resources to local directories
npm install @d-zero/replicator@d-zero/replicatorウェブページとそのリソースをレスポンシブ画像対応でローカルディレクトリに複製するツールです。複数のURLを並列処理し、効率的にリソースを取得します。
``bash`
npm install @d-zero/replicator
`bash`
npx @d-zero/replicator
#### オプション
- --version: バージョンを表示(注: -vは--verboseのエイリアス)-o, --output
-
: 出力ディレクトリ(必須)
- -t, --timeout : リクエストタイムアウト(ミリ秒、デフォルト: 30000)
- -d, --devices : デバイスプリセット(カンマ区切り、デフォルト: desktop-compact,mobile)
- -l, --limit : 並列処理数の上限(デフォルト: 3)
- --interval : 並列実行間の間隔(デフォルト: なし)
- 数値または"min-max"形式でランダム範囲を指定可能
- --only : ダウンロード対象を限定(page または resource)
- -v, --verbose: 詳細ログモード#####
--only オプション-
page: HTMLページのみをダウンロード(リソーススキャンをスキップして高速化)
- resource: リソース(CSS、JS、画像など)のみをダウンロード(HTMLページを除外)
- 未指定: すべてのファイルをダウンロード(デフォルト動作)#### 利用可能なデバイスプリセット
-
desktop: 1400px幅
- tablet: 768px幅
- mobile: 375px幅(2倍解像度)
- desktop-hd: 1920px幅
- desktop-compact: 1280px幅
- mobile-large: 414px幅(3倍解像度)
- mobile-small: 320px幅(2倍解像度)#### 使用例
`bash
単一URL(デフォルトデバイス: desktop-compact, mobile)
npx @d-zero/replicator https://example.com -o ./output複数URLを並列処理
npx @d-zero/replicator https://example.com/page1 https://example.com/page2 -o ./output並列数を制限
npx @d-zero/replicator https://example.com/page1 https://example.com/page2 -o ./output --limit 2カスタムデバイス指定
npx @d-zero/replicator https://example.com -o ./output --devices desktop,tablet,mobileタイムアウト指定
npx @d-zero/replicator https://example.com -o ./output --timeout 60000HTMLページのみダウンロード(高速)
npx @d-zero/replicator https://example.com -o ./output --only pageリソースのみダウンロード(HTMLを除外)
npx @d-zero/replicator https://example.com -o ./output --only resource
`$3
`typescript
import { replicate } from '@d-zero/replicator';// 単一URL
await replicate({
urls: ['https://example.com'],
outputDir: './output',
});
// 複数URLを並列処理
await replicate({
urls: [
'https://example.com/page1',
'https://example.com/page2',
'https://example.com/page3',
],
outputDir: './output',
limit: 2, // 最大2つのURLを同時処理
});
// カスタムデバイス
await replicate({
urls: ['https://example.com'],
outputDir: './output',
devices: {
desktop: { width: 1400 },
mobile: { width: 375, resolution: 2 },
},
timeout: 30000,
verbose: true,
});
// HTMLページのみダウンロード
await replicate({
urls: ['https://example.com'],
outputDir: './output',
only: 'page',
});
// リソースのみダウンロード
await replicate({
urls: ['https://example.com'],
outputDir: './output',
only: 'resource',
});
`機能
- 並列処理: 複数のURLを並列で効率的に処理
- メモリ効率: リソースを直接ディスクに保存してメモリ使用量を最小化
- 選択的ダウンロード:
--onlyオプションでHTMLページのみまたはリソースのみをダウンロード可能
- レスポンシブ画像対応: 複数のデバイス幅で要素やメディアクエリのリソースを取得
- 遅延読み込み対応: ページを自動スクロールしてloading=lazyやIntersectionObserver`ベースのコンテンツを取得MIT