CommonCrawl.Net は、Common Crawl データセットと対話するために設計された堅牢な .NET ライブラリです。データセットのメタデータの取得、再開機能が組み込まれたファイルのダウンロード、および GZIP 圧縮された WARC ファイルの効率的な解析プロセスを簡素化します。
- DataSetHandler:
index.commoncrawl.orgから利用可能な Common Crawl データセットバージョン(コレクション)のリストを自動的に取得してキャッシュします。 - DownloadHandler: 中断されたダウンロードの再開(HTTP Range リクエスト)をサポートする信頼性の高いファイルダウンロードユーティリティ。
- GzWarcReader: URL またはローカルストリームから WARC(Web ARChive)ファイルを直接解析するための高性能リーダー。GZIP 解凍を透過的に処理します。
using CommonCrawl.Handlers;
using CommonCrawl.Utils;
// 最新のデータセットバージョンを取得
var latestInfo = await DataSetHandler.Instance.GetLatestAsync();
Console.WriteLine($"Latest Crawl: {latestInfo.Id}");
// パス(WARC, WAT, WET など)のダウンロード URL を取得
var pathUrls = CommonCrawlUrlSplicer.FromCollectionInfo(latestInfo.Id);
Console.WriteLine($"WARC Paths URL: {pathUrls.WARC}");using CommonCrawl.Handlers;
string url = "https://data.commoncrawl.org/crawl-data/CC-MAIN-2023-50/warc.paths.gz";
string destination = "warc.paths.gz";
// レジューム(再開)機能付きでダウンロード
await DownloadHandler.Instance.DownloadAsync(url, destination);using CommonCrawl.Readers;
string warcUrl = "https://data.commoncrawl.org/.../file.warc.gz";
// URL から直接 WARC レコードをストリーミングして解析
await foreach (var block in GzWarcReader.Instance.ReadAsAsyncEnumerable(warcUrl))
{
Console.WriteLine($"Record Type: {block.Type}");
if (block is WarcResponseRecord response)
{
Console.WriteLine($"Target URI: {response.TargetUri}");
}
}