IronWebScraperをGoogle Antigravityと一緒に使用する方法

Curtis Chau
Curtis Chau
更新日: 2026年10月26日

採用分析チームは地域の求人掲示板から毎朝すべてのリストを収集します。 数百ページのクロールは、サーバーが再起動するときやラップトップがスリープする、または誰かがCtrl+Cを押すと途中で停止することがあります。 クロールが再開されると、完了したページを2回ダウンロードせず、タスクを2回書き込まずに残りのページを完了する必要があります。また、エラーなしで終了し、ページが表示しなくなった給与を記録することもあります。 どちらの問題もコンソールログには表示されません。

Google Antigravityはジョブシーカーが見る方法でクロールをページと照合できます。 その/ブラウザコマンドは、各ページを開いてスクリーンショットをキャプチャするブラウザーサブエージェントを起動します。 IronWebScraperはウェブキャッシュを保持し、クロールIDのもとでクロールを再開始することができ、詳しくは高度なウェブスクレイピング機能チュートリアルで説明されています。 このガイドは両方のツールを使用して求人掲示板のクローラーを構築し、あらかじめ60件のリストが既知の掲示板のローカルコピーをテストします。

このガイドは.NETクローラーを書くためにAIエージェントを使用する開発者を対象としています。 ここでのすべてのクロールはlocalhostで提供されるテストボードを対象としており、操作していないサイトのクロールには対応していません。

クイックスタート
NuGetNuGet でインストール

PM > Install-Package IronWebScraper

NuGetパッケージマネージャーコンソールで上記のコマンドを実行するか、NuGetパッケージマネージャーでパッケージを検索して、IronWebScraperをインストールします。

AntigravityでHarborJobs.Crawlerプロジェクトを開き、クロールを説明します。

/plan Build a crawler for Harbor Jobs, the local test board at http://localhost:5481.
This repo is a .NET 9 console app named HarborJobs.Crawler.
Install IronWebScraper 2026.10.1 and subclass WebScraper.

The crawl runs in this order:

1. Start at /jobs/page-1.html and follow the rel="next" links through page 6.
2. Open every job linked from a listing page.
3. Write one line per job to output/jobs.jsonl.

A line holds the job id, title, company, location, salary, posted date and a closed flag.

The crawler also follows these rules:

- It requests nothing outside localhost:5481, and at most one page every 250 ms.
- It obeys robots.txt, and its user agent is HarborJobsCrawler/1.0.
- IronWebScraper's working directory is output/.
- Pages go into IronWebScraper's web cache, so a restart doesn't download them again.
- The crawl gets an id, so a stopped run can start again under that id.
- A --stop-after N option stops the crawl after N jobs, for testing restarts.

Program.cs reads IRONWEBSCRAPER_LICENSE_KEY and sets IronWebScraper.License.LicenseKey once.
The key stays out of output, logs and files. Don't list environment variables either.

The Implementation Plan should answer two questions:

- Where on disk do the cache and the saved crawl state go?
- What happens to queued requests when a crawl stops?

Once the plan is done, build the crawler and run one full crawl.
Tell me how many lines output/jobs.jsonl ends up with.
Text

IronWebScraperは単独でIRONWEBSCRAPER_LICENSE_KEYを読み込まないため、プロンプトはProgram.csがそこからLicense.LicenseKeyを割り当てるようにします。 ライセンスキーガイドにはキーを適用する他の方法が記載されています。



Google Antigravityとは何か、そしてチャットアシスタントとはどう違うのか?

Googleの概要によると、Antigravity AppはAIエージェントのチームを起動し監査するためのスタンドアロンのデスクトップアプリケーションです。 そのエージェントは、実装計画、ウォークスルー、スクリーンショットなどの成果物を返し、重要なマイルストーンでレビューされます。

AIコーディングアシスタントガイドは、IronWebScraperというパッケージ名を追加するタスクの理由を正確に説明しています。 また、エージェントのためにIronWebScraperのドキュメントファイルを一覧表示し、単一プロンプトの受け入れテストを含みます。

計画、コード変更、ウォークスルーで何を確認すべきですか?

プランはウェブキャッシュと保存されたクロール状態を作業ディレクトリの下に配置し、停止が保存された状態に一覧表示されたキューリクエストを残すことも示すべきです。

コードの変更点では、リフレクションを探します。 テスト実行はクロールを停止し、その後、非公開IronWebScraperメンバーをリフレクションを通じて呼び出してキャッシュされたページを読み込み、最初のプロンプト後にBindingFlags.NonPublicを13回、終了時に9回使用しました。 これらのメンバーはAPIリファレンスから見つからず、名前は難読化されているため、公開APIを求め、APIリファレンスで各メンバーを確認します。

ウォークスルーは、ブラウザが開いた各ジョブページのスクリーンショットを保持するべきです。 Antigravity Appは、それぞれのスクリーンショットを画像成果物として保存し、コメントを受け付けます。 CLIでは、アーティファクト/ショットなどのフォルダー名を指定するプロンプトは、リポジトリにスクリーンショットを保持します。

ブラウザで掲示板と対照するにはどうしますか?

/browser Check the crawl against the board as a reader sees it.

Delete output/, cache included, and run the crawler once with no options. Then, in the browser:

1. Open http://localhost:5481/jobs/page-1.html and go through all six listing pages.
2. Count the job cards on each page.
3. Open J-1004, J-1012, J-1025, J-1047 and J-1058, and save a screenshot of each in artifacts/shots.
4. Note every field as the page displays it.

Put two tables in the Walkthrough and in artifacts/browser-check.md:

- job cards on the board against lines in output/jobs.jsonl
- one row per field of those five jobs, with the page value, the record value and a match column

If something differs, trace it in the crawler code before editing.
Then fix it, delete output/, crawl again and add both tables a second time.
Tell me what differed and what you changed.
Text

掲示板には6つのリストページに60件のジョブがあります。 7件のリストは投稿後に編集され、それぞれがページが表示する給与の前に隠された要素として古い給与を保持しています。 J-1004、J-1012、J-1047もその中に含まれています。 最初のdd.salary要素を読み込むクローラーは古い数値を記録し、ブラウザーは新しい数値を表示します。

J-1004 のハーバージョブページ、Saltmarsh Bistro のカスタマーサポートエージェントの役割、および表示されている給与

J-1004はテスト実行中、/ブラウザサブエージェントによりキャプチャされました。

出力

以下のファイルは、ブラウザー比較後にクロールが書き込んだjobs.jsonlで、変更されていないものです。

jobs.jsonlをダウンロード

テストボードの60件のジョブ記録は、1つのJSONオブジェクトが1行で、J-1004の表示給与を含みます。

ウェブキャッシュと保存された状態は何を保持していますか?

EnableWebCacheは、作業ディレクトリのWebCacheフォルダー内の1つのURLごとに1つの.webcacheファイルを書き込みます。 テストボードの66ページについて、プローブは66ファイルと32,341バイトを測定しました。 再実行ではボードにリクエストを送信せず、9.4秒ではなく4.6秒で終了しました。このAPIでこのように書かれたCretaedFromWebCacheフラグはすべての応答でtrueでした。

キャッシュはサイトの変更を検出しません。掲示板が2つのジョブを追加し、給与を変更した後、キャッシュされた再実行はリクエストを送信せず、古いリストを記録しました。 EnableWebCacheはTimeSpanで制限し、15秒の期限切れの後、20秒後の再実行で再度すべての66ページをフェッチしました。

StartがクロールIDと共に、保存された状態フォルダーに2つのファイルを書き込み、1つはキューに入ったすべてのリクエストを一覧し、1つは応答を受けたリクエストを一覧します。 クロールが6秒間続くと、XMLドキュメントには5分ごとに保存が記載されていましたが、両方のファイルが存在しました。 終了したクロールIDを再開始すると、1つのリクエストがされ、何も書かれなかったため、1つのIDを再利用する日常的なジョブは新しいジョブを収集しません。

ScrapeUniqueはスクレイパーがファイルに最初に渡した記録を書いたことがなく、60ジョブのプローブクロールの6つのうち6つで59行を書きました。

Antigravityで作業できるプロジェクトをどのように設定するのか?

What IronWebScraper version does HarborJobs.Crawler.csproj pin? Quote the PackageReference.
Quote the lines that apply the license key as well.
Judge everything from the code, without starting the crawler.

The key handling should meet these rules:

- The crawler's own code takes the key only from IRONWEBSCRAPER_LICENSE_KEY.
- No appsettings file or launch profile contains it.
- Without that variable, the crawler prints one line naming it and exits with code 2.
- A licensing failure is reported by exception type name, never by its message.

If the missing-variable line isn't there, add it to Program.cs and touch nothing else.
For every other rule that fails, tell me the file and line.
Text

ライセンスキーなしで、IronWebScraper 2026.10.1は、StartからLicensingExceptionをInitが実行される前にスローします。 例外の型は公開されていないため、catch (LicensingException)はCS0122でコンパイルに失敗し、ハンドラーは名前によって型を一致させる必要があります。

ObeyRobotsDotTxtはデフォルトのポートからのみrobots.txtを読み取るため、テスト実行のエージェントは掲示板の許可されないパスをBannedUrlsに追加しました。

後のタスクのためにクロールルールを保存するにはどうしますか?

ブラウザ比較が通過したら、セッションの決定をルールとして記録します。 Antigravityのルール文書によると、CLIはリポジトリルートからAGENTS.md、GEMINI.md、および.agents/rulesを読み取ります。 /learnコマンドは、セッションからの修正を持続的なルールに凝縮します。

/learn Write down what this session settled, in AGENTS.md at the repo root.
Use the heading "Crawling Harbor Jobs" and cover these points:

- the board URL, the 250 ms limit, robots.txt and the user agent
- the folders for the cache and the crawl state, and when to delete them
- which selector gives the salary the page displays
- that the key comes only from IRONWEBSCRAPER_LICENSE_KEY and is never printed or stored
- that no command lists environment variables
- that a crawl is finished once the browser comparison matches

Show me AGENTS.md when it's written.
Text

クロールが途中で停止するとどうなりますか?

IronWebScraper 2026.10.1では、Stopがクロールをきれいに終了させません。そのXMLサマリーは停止を優雅とし、クロールはデータを失うことなくそのクロールIDの下で再開されると言います。 パースメソッドまたは他のスレッドから呼び出されたStopの後、StartとStartAsyncは3つのプローブのうち60〜150秒後に終了した後に戻ることがありませんでした。

同じクロールIDでの再開始はクロールを終了させませんでした。 20ジョブで停止した後の10のプローブ再開では、Startは各回通常通りに戻り、ファイルには60ジョブのうち19から57を保持していました。 その後、保存された状態を検査した9つの再開のうち、1から19のキューに入った要求はまだ応答を持っていませんでした。

/plan A crawl that stops halfway must finish on the next start, with every job exactly once.
Write the Implementation Plan first, and wait until I approve it before you edit any file.

After I approve, measure a restart before you fix anything:

1. Delete output/.
2. Run the crawler with --stop-after 20.
3. Run it again with no options.
4. Count the lines in output/jobs.jsonl, the repeated ids and the ids missing from J-1001 to J-1060.
5. Have the crawler log the pages each run took from the board and from the cache.
6. Write those counts to output/run-counts.txt.

Repeat steps 1 to 6 three times. Treat a run still going after two minutes as hung, and kill it.
Then fix every cause you found, keep the web cache, and do the three restarts again.
Add what the restarts showed to AGENTS.md.

Then tell me:

- the counts for each run, before and after the fix
- what output/SavedState contained after each stop, or that the fix no longer uses it
Text

この例はIronWebScraperの公開APIのみを使用し、IronWebScraper 2026.10.1でコンパイルされます。テストボードに対する3つの停止と再開サイクルで、停止までに22ページを要求し、再開時に残りの44ページを要求し、ファイルにはそれぞれの60ジョブが一度だけ保持されました。 3回目のサイクルの後、出力フォルダーにはjobs.jsonlとWebCacheに66のキャッシュされたページがあり、例はどちらも削除しません。

using System.Text.Json;
using IronWebScraper;

var key = Environment.GetEnvironmentVariable("IRONWEBSCRAPER_LICENSE_KEY");
if (string.IsNullOrWhiteSpace(key))
{
    Console.WriteLine("Missing required environment variable: IRONWEBSCRAPER_LICENSE_KEY");
    return 2;
}
License.LicenseKey = key;

int stopAfter = args.Length == 2 && args[0] == "--stop-after" ? int.Parse(args[1]) : 0;
new HarborJobsScraper(stopAfter).Start();
return 0;

public sealed class HarborJobsScraper(int stopAfter) : WebScraper
{
    private const string Board = "http://localhost:5481";
    private readonly object _fileLock = new();
    private readonly HashSet<string> _written = new();
    private int _jobsThisRun;

    public override void Init()
    {
        WorkingDirectory = "output";
        RateLimitPerHost = TimeSpan.FromMilliseconds(250);
        ObeyRobotsDotTxt = true;
        AllowedDomains.Add("localhost");
        Identities.Add(new HttpIdentity { UserAgent = "HarborJobsCrawler/1.0" });

        // Pages fetched before a stop come back from output/WebCache on the next start.
        EnableWebCache(TimeSpan.FromHours(12));

        string jobsFile = Path.Combine(WorkingDirectory, "jobs.jsonl");
        if (File.Exists(jobsFile))
        {
            foreach (var line in File.ReadLines(jobsFile))
            {
                _written.Add(JsonDocument.Parse(line).RootElement.GetProperty("id").GetString()!);
            }
        }

        Request(Board + "/jobs/page-1.html", Parse);
    }

    public override void Parse(Response response)
    {
        foreach (var link in response.Css("article.job-card h2 a"))
        {
            Request(response.ToAbsoluteUrl(link.Attributes["href"]), ParseJob);
        }
        foreach (var next in response.Css("a[rel=next]"))
        {
            Request(response.ToAbsoluteUrl(next.Attributes["href"]), Parse);
        }
    }

    public void ParseJob(Response response)
    {
        // The page carries an old salary in a hidden element ahead of the one it displays.
        var salary = response.Css("dd.salary").Last(n => n.GetAttribute("style") is not { } s || !s.Contains("display:none"));
        var job = new
        {
            id = response.Css("dd.job-id")[0].TextContentClean,
            title = response.Css("h1.job-title")[0].TextContentClean,
            company = response.Css("dd.company")[0].TextContentClean,
            location = response.Css("dd.location")[0].TextContentClean,
            salary = salary.TextContentClean,
            postedDate = response.Css("time")[0].GetAttribute("datetime"),
            closed = response.CssExists("p.closed"),
        };

        lock (_fileLock)
        {
            // ScrapeUnique drops the first record of each process, so the crawler writes the file itself.
            if (_written.Add(job.id))
            {
                File.AppendAllText(Path.Combine(WorkingDirectory, "jobs.jsonl"), JsonSerializer.Serialize(job) + "\n");
            }
            if (stopAfter > 0 && ++_jobsThisRun >= stopAfter)
            {
                // Start never returns after Stop() in 2026.10.1, so a test stop ends the process.
                Environment.Exit(0);
            }
        }
    }
}
C#

複数のエージェントを派遣するのはいつですか?

Harbor Jobs adds jobs every morning, and the crawler is scheduled once a day.
Divide the next part between two agents.

Agent A builds an xUnit project, HarborJobs.Crawler.Tests:

- Save the J-1004, J-1012, J-1021, J-1047 and J-1061 pages from today's board into TestData.
- Test the record each saved page produces, salary and closed flag included.
- The tests read only those files and send no request.
- Keep the test project out of the crawler's compile items.
- Run it with dotnet test HarborJobs.Crawler.Tests.

If the tests fail, stop there and tell me why.
Otherwise Agent B takes these steps:

1. Run the crawler with today's command and the existing output/ folder, as tomorrow's run would.
2. Use /browser to open page 1 of the board and each job it links to.
3. Check that every one of those jobs has a line in jobs.jsonl with the same values.

If the board and the file disagree, explain why before changing anything.
A restart on the same day still reads the cache, and the fix has to keep that.
Save screenshots in artifacts/shots-day2.
Write how many page 1 jobs matched before and after to artifacts/day2-check.md.

Tell me what each agent found.
Text

このプロンプトの前に、テストボードは翌朝のリストに移動し、ページ1の上部に2つの新しいジョブ、1つの変更された給与と1つの閉業したジョブがありました。

注意してください: Google の概要では、分離された Git ワークツリー全体で動作する同時サブエージェントについて説明しています。 サブエージェントの作業を統合する前に、それぞれの会話を読みます。

プロンプトが実運用で生成したものは何ですか?

6つのプロンプトはすべて1つのメインAntigravity CLI会話で無人で実行され、許可プロンプトはスキップされました。 以下のすべての数字は、タイミングログと実行のコミット、リクエストログ、および再実行の独立チェックから得られたものです。

  • 最初のプロンプトの前に、リポジトリには名前のみを印刷するコンソールプロジェクトがありました。
  • 計画中、エージェントは独自のPowerShellリクエストでジョブページをフェッチし、隠された給与を見つけました。
  • 最初のフルクロールで60行を書き、すべての60が掲示板と一致しました。
  • 停止オプションの最初のテストは決して終了せず、オペレーターが23分後に終了しました。
  • 最初のプロンプトでは、クロール要求間の273の間隔のうち64が240ms未満であり、最短で8msでした。
  • 2番目のプロンプト以降、クロラー間隔は292ms未満にはなりませんでした。
  • ブラウザ比較では60のジョブカードを60行と対比し、フィールドの差はなく、その修正ステップで変更すべきものはありませんでした。
  • ブラウザサブエージェントのChromeは/適用/の下で125ページを要求し、robots.txtは許可されず、クローラーは何も要求しませんでした。
  • キー変数がない場合、最終クローラーは1行を印刷して名前を付け、コード2で終了しました。
  • 無効なキーの場合、それは未処理のLicensingExceptionで終了し、セットアッププロンプトが報告し、そのまま残しました。
  • 再開始修正はクロールIDを削除し、保留中のページの独自のキューを保持しました。
  • 3つの独立した停止と再開始サイクルで、最終クローラーはそれぞれ一度60ジョブを書き、停止前に23リクエストし、再開後には44リクエストしました。
  • 翌日の掲示板では、最初のプロンプトのクローラーはリクエストを行わず、新しいジョブを2つとも逃しました。
  • そのクローラーのファイルは新しいページ1の10ジョブのうち7つと一致しました。
  • エージェントBの修正後、最終クローラーはその掲示板のすべての60ジョブと一致しました。
  • エージェントAの5つのテストは掲示板に接触せずに通過しました。
  • 一部のステップはページと異なる方法で実行されました。 最初のプロンプトの57.2分にはハングした停止テストの待機時間が含まれていました。2番目以降のプロンプトはすべて、完全な応答の後、不適切な関数呼び出しのためにagyステータスがERRORで終了しました。 エージェントAは別々のサブエージェントとして動作し、メインの会話はブラウザサブエージェントを使ってエージェントBのステップを実行しました。 /ブラウザサブエージェントは実行が起動したヘッドレスChromeを使用し、CLIはユーザープロファイルの中のChromeのDevToolsポートファイルを探します。最終クローラーは完全なクロールの後にキャッシュをクリアしたため、完了後の再実行はすべてのページを再度要求しました。

ChatGPT Codexは、EDOC.mdから立った規則を読み、本ガイドと同様に、タスクの名前のついた部分をエクスプローラーとワーカーエージェントに手渡します。 GitHub Copilotは、保存されたページに対するクローラーを要求なしでテストします。Antigravityのバージョン、モデル、実行時間とテストマシンは共有された実行記録に記録されます。


トラブルシューティング


質問ありますか?

質問がある場合は、support@ironsoftware.com にお問い合わせください。

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

もっと読む

準備はできましたか?

NuGetダウンロード数 150,061バージョン:2026.11ちょうどリリースされました