IronWebScraperをChatGPT Codexと共に使用する方法

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

価格設定チームは、毎晩オンラインカタログの価格を記録し、前夜と比較します。 このカタログは5ページにわたっており、各ページは他のページにリンクしています。 クロール中に1ページが失敗した場合でも、クロールは終了し、ファイルが書き出されます。そしてその後、比較で欠落したページ上のすべての製品が廃止されたものとしてリストされ、変更されなかった価格に基づいてチームは行動します。

ChatGPT CodexはOpenAIのコーディングエージェントです。 リポジトリ内でファイルを読み、編集し、dotnet runのようなコマンドを実行し、変更を報告します。それはターミナル、IDE拡張、ChatGPTデスクトップアプリ、またはクラウドから行われます。 IronWebScraperは、プロジェクトが拡張する基本クラスとして.NETでのクロールを提供します。 基本クラスはリクエストをキューに入れ、ホストごとに制限をかけ、失敗をリトライし、スクレイピングした行をJSON Linesファイルに書き込みます。

このガイドはCodexにローカルホストで提供されるテストカタログ、ルールファイル、2晩分の価格を提供します。 カウントを求めるプロンプトはその記録をファイルに求めるため、Codexが報告する各カウントはデータで裏付けられます。 クローラーが書かれる前に、プローブがIronWebScraperがそのサイトで失敗したページ、robots.txt、独自の出力ファイルをどのように処理するかを測定します。

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

PM > Install-Package IronWebScraper

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

.NET 9 コンソールプロジェクトでDataおよびTestDataフォルダを含み、ポート5461でテストカタログを実行し、Codexを開始します。

$ironwebscraper Add IronWebScraper 2026.10.1 to this console app and read the first catalogue page.

The test catalogue runs at http://localhost:5461/catalog/page-1.html.
Program.cs crawls that page alone and writes out/quickstart.csv, one row per product.
The CSV has these columns:

- sku, from the data-sku attribute
- name
- price, from the data-price attribute
- shown, the price text the page displays

The price monitor reads IRONWEBSCRAPER_LICENSE_KEY in code and assigns it to License.LicenseKey.
Keep the value out of output, files and logs.
Don't run anything that lists environment variables.

After three failed builds or runs, stop and paste the last error.
Otherwise, count the CSV rows and tell me the number.
Text


ChatGPT Codexとは何か、そしてそれが.NETのウェブスクレイピング作業にどのようにフィットするか

Codexは許可された権限内で動作します。 Codex CLI ドキュメントはインストールとターミナルでの使用をカバーしており、オープンソースレポジトリはそのリリースを公開しています。

Codexが発明したメンバーはビルドに失敗します。 コンパイル、実行し、静かにページをスキップするクローラーはビルドを通過し、このガイドはその2回目の失敗に対処します。

IronWebScraperは.NET Standard 2.0と2.1アセンブリを提供し、サーバーが返すHTMLを解析します。 このガイドのクロールはサードパーティサイトには到達しません。

IronWebScraperのプロンプトを書き、それにCodexを設定する方法

クイックスタートプロンプトは開始ページ、フィールド、出力ファイルを命名します。スナップショットとサービスプロンプトはサイトのルールにData/README.mdを参照します。

Codexは、作業ディレクトリからリポジトリのルートまでのすべてのフォルダー内の.agents/skillsをスキャンします。 IronWebScraperのskill.mdを.agents/skills/IronWebScraper/SKILL.mdとして保存することで、$ironwebscraperの言及が解決されます。 スキルのサンプルプログラムはIronWebScraper 2026.8.1をターゲットとしていますが、このガイドでは2026.10.1をインストールします。

Codexは、実行が開始される際にAGENTS.mdを1度読み込みます。 レポジトリルートから作業フォルダまで歩き、より深いファイルがより浅いファイルを上書きします。 実行中に書き込まれたファイルは次の実行に適用されます。 /initコマンドは最初のドラフトを生成します。

Create AGENTS.md in the repository root with a Price watch heading.
Give it these rules, one per line:

- IronWebScraper 2026.10.1 does all fetching and parsing.
- No HttpClient code, HtmlAgilityPack or AngleSharp.
- Data/README.md describes the site, the snapshot and the change report. It overrides anything else.
- Crawl localhost only: the test site on port 5461, or a listener a test starts.
- Every scraper adds the patterns */cart/* and */account/* to BannedUrls.
- RateLimitPerHost stays at one second or more.
- Init adds an HttpIdentity whose UserAgent is the one Data/README.md names.
- Data/ and TestData/ are read-only.
- Check IronWebScraper members in the ironwebscraper skill and the installed IronWebScraper.xml.
- When a probe against the test site disagrees with either of them, the probe wins.
- Any count you report comes from a file written that turn, and the reply names it.
- The key stays in IRONWEBSCRAPER_LICENSE_KEY.

Show me the file when it's done.
Text

ルールはHttpIdentityをInitに追加し、すべてのリクエストがクローラーを命名するようにします。 ハブのクローリングデフォルトは、IronWebScraperがそれなしで送信する内容を示します。

IronWebScraperを追加し、キーを適用する方法

Show me the IronWebScraper PackageReference in PriceWatch.csproj and the version NuGet restored.
Paste all of what dotnet list package --include-transitive prints after that.
Leave every package reference as it is.
Text

IronWebScraper 2026.10.1はIronSoftware.Common 2026.4.2およびIronSoftware.System.Drawing 2026.8.2に依存しています。試行ランのパッケージリストには30の推移パッケージが表示され、その中にはSixLabors.ImageSharp 3.1.12、Grpc.Net.Client 2.62.0、およびPolly 8.6.6が含まれます。リリースを固定する前にIronWebScraperのチェンジログを確認してください。

IronWebScraperはIRONWEBSCRAPER_LICENSE_KEYを無視するため、その名前の下にキーを保持するコードは、最初のクロールの前にLicense.LicenseKeyを割り当てます。

Move the key line into Startup.ApplyIronWebScraperKey and call it at the top of Program.cs.
After the assignment, the method prints License.IsLicensed.

Next, find out what IronWebScraper does without a key.
Launch three child copies of the program, each with --licence-check N, set up like this:

1. The first child runs with IRONWEBSCRAPER_LICENSE_KEY removed from its environment.
2. The second keeps the variable, but --no-startup stops it from calling Startup.
3. The third keeps the variable and calls Startup.

Each child crawls catalogue page 1 into out/licence-check-N.csv.
Log every child in out/licence-check.csv with these columns:

- run and IsLicensed
- exception type, with no message
- rows written, and whether the child's CSV exists

Tell me which of the three wrote rows.
Text

ライセンスキーのページにはキーを供給する他の方法が記載されています。

IronWebScraperは失敗したページ、robots.txt、および出力ファイルをどのように処理するか

ショッピングウェブサイトガイドは製品をScrapeで書き出し、カテゴリパーサから次のページのリンクに従います。 IronWebScraper 2026.10.1の4つの動作により、夜間の価格ファイルが信頼できるかどうかが決まります。そしてプローブはそれぞれをテストカタログに対して測定しました。

  • カタログページ3が毎回503を返す中で、IronWebScraperはデフォルトHttpRetryAttemptsの下で9回要求し、エラーなしでそれを削除しました。 出力には47製品のうち37が含まれていました。
  • ObeyRobotsDotTxtはデフォルトで有効になっていますが、/robots.txtへのリクエストはテストサイトに到達せず、robots.txtが許可しない/cart/以下のリンクがフェッチされました。 IronWebScraperはデフォルトポートでのみrobots.txtを探します。 */cart/*パターンがBannedUrlsでそれらのリンクを除外しました。
  • Scrapeはファイルに追加します。同じファイルに対して2回の実行が47製品のために94行を残しました。
  • ScrapeUniqueは最初に書き込むレコードを失います。 47製品の3回のフレッシュランでそれぞれ46行が書き込まれ、毎回LK-1001が欠落していました。
Probe how IronWebScraper treats the test site, in a console app at scratch/crawl-probe/.
Add a Compile Remove item so PriceWatch.csproj skips scratch/**.
Apply the key as Startup does.
Each case gets its own scraper, output folder and try block.

Measure these cases from Parse calls, FailedUrls and the files written:

- queue every nav.pager link from every page, then compare Parse calls with pages
- Scrape the same 10 rows into one file in two separate runs, and count lines after each
- ScrapeUnique 10 different rows into a new file, and count the lines
- request /probe/once-503.html and /probe/always-503.html, and note what reaches Parse
- leave ObeyRobotsDotTxt on and request /probe/blocked/page.html, which robots.txt disallows
- read LK-1045 on catalogue page 5: the price text and the data-price attribute

Then have the explorer agent read IronWebScraper.xml and the ironwebscraper skill, editing nothing.
It reports what both say about Scrape, ScrapeUnique, HttpRetryAttempts and ObeyRobotsDotTxt.

Write every finding into out/crawl-probe.csv, with a quote from the run, the XML or the skill.
Flag each row where a source and the probe disagree, and list those rows for me.
Text

スナップショットクローラーを構築する方法

Data/README.mdはすべてのページが1からMまでParseに達し、リクエストが失敗しないものを完全なスナップショットとして定義しています。 LK-1045の表示テキストが$1,249.00である一方で、データ価格属性が1249.00を保持しているため、価格はdata-price属性から取得します。

Have the worker agent write Services/CatalogueCrawler.cs.
It builds a snapshot as Data/README.md describes.

PriceWatch takes two commands:

- --snapshot --date YYYY-MM-DD crawls every catalogue page into out/snapshots/<date>.csv
- --compare OLD NEW writes out/changes-NEW.csv from those two snapshot files

Use what the probe found when the crawler writes and checks its output:

- every run starts a new output file, so no rows carry over from an earlier run
- the snapshot is refused when FailedUrls is above zero
- it is also refused when a page from 1 to M never reached Parse
- a refusal prints FailedUrls and the page numbers that reached Parse
- the price column comes from data-price
- the was column comes from span.price-was, without the $ sign or commas

Run --snapshot --date 2026-10-15.
Tell me the row count and the number of pages, both read from the snapshot file.
Text

Codexが報告する価格変更をチェックする方法

The store changed its prices overnight.
Run --snapshot --date 2026-10-16, then --compare 2026-10-15 2026-10-16.

Check the report with code kept apart from the crawler.
That code reads both snapshots and out/changes-2026-10-16.csv.
It writes out/changes-check.csv with these columns:

- sku
- the change the snapshots show
- the change the report lists
- match, yes or no

Give me the count of each change type in the report, plus any row that doesn't match.
Text

出力

レポートはクローラーがテストランの2晩目に書いたファイルで、変更されていません。

3つの価格低下、3つの価格上昇、2つの新製品、1つの削除された製品、および1つのストック変更を含む変更レポートCSV

テストランの変更レポート、out/changes-2026-10-16.csvはプレーンテキストとして表示されます。

カタログページが失敗したときに何が起こるか

Catalogue page 3 now answers 503 to every request.
Show me that no snapshot gets saved in that state.

Run --snapshot --date 2026-10-17.
out/snapshots/2026-10-16.csv must stay identical, byte for byte.
Write out/failure-check.csv, holding these values:

- the exit code and the message printed
- FailedUrls and the pages that reached Parse, copied from that message
- whether out/snapshots/2026-10-17.csv exists
- the SHA-256 of the 2026-10-16 snapshot before and after the run

Say whether the snapshot was refused and whether the two hashes are equal.
Text

スクリーンショットから価格を確認する方法

Codexは画像をコンテキストとして受け入れます。 -iフラグ(ロングフォームは--image)をcodex execまたはcodex exec resumeに渡すか、インタラクティブコンポーザーに貼り付けます。

ロードランタン$24.99、リッジテント2P$289.00、サミットパック45L$179.95のテストカタログページ1

テストランに添付されたスクリーンショット、テストサイトの1ページ目が最初の晩に提供されたものとして。

A customer sent the screenshot I attached with -i.
They say the Ridge Tent 2P price on it is wrong.
Leave the code alone and go through this in order:

1. Read the name, price and stock of the first three products in the image.
2. Compare them with out/snapshots/2026-10-15.csv and out/snapshots/2026-10-16.csv.
3. Save the comparison as out/screenshot-check.csv.

Then quote the heading shown in the image.
Tell me which day's catalogue it shows and what the tent costs now.
Text

誤送信された価格アラートをデバッグする方法

Work out why the 2026-10-16 price alerts went out wrong.
These files describe what happened:

- Data/alert-complaint.md lists four problems.
- Output/price-alerts-2026-10-16.csv is the file that was sent.
- Logs/price-check-2026-10-16.log reports success.
- Logs/store-access-2026-10-16.log is the store's record of the price check's requests.

Start with the explorer agent.
It reads Jobs/LegacyPriceCheck.cs, the two logs and the alert file.
Don't edit any code.
A script under scratch/ may read the files if that helps.

Write out/legacy-diagnosis.md, and include:

- the code line that causes each problem
- why the job log still said it succeeded
- the smallest fix for each problem, backed by a row of out/crawl-probe.csv

Then tell me each problem and its cause, one line per problem.
Text

編集を許可する前に診断を見直してください。 レガシージョブはStartが返った後に成功ラインをログし、FailedUrlsを読むことはありませんでした。

クローラーをテスト済みサービスに変える方法

Ask the worker agent for a PriceWatchService class with these properties:

- A Microsoft.Extensions.DependencyInjection container can resolve it.
- A WatchOptions record configures it with the date, base URL, output folder and rate limit.
- It keeps every rule from Data/README.md and every check CatalogueCrawler makes.
- PriceWatchService.cs stays below 150 lines.
- Every public member carries an XML doc comment.
- Nothing calls Jobs/LegacyPriceCheck.cs.

Then take the 2026-10-16 snapshot again through the service, into out/final/2026-10-16.csv.
Compare it with out/snapshots/2026-10-16.csv and list every difference for me.
Text

IronWebScraperは自分でフェッチした応答だけを解析します。 Responseは保存されたHTMLをロードする公の方法を持たず、ローカルファイルアドレスをRequestに渡してもParseコールが生成されず、エラーもありませんでした。 Codexサンドボックステストで、Windows PowerShellのHttpListenerコンストラクターはPlatformNotSupportedExceptionをスローしました。 ループバックにバインドされたTcpListenerが機能したため、テストプロンプトは保存されたページを一から提供します。

Add an xUnit project at tests/PriceWatch.Tests, in one solution with the main project.
Keep tests/** out of PriceWatch.csproj.
The tests apply the key through Startup.ApplyIronWebScraperKey.

IronWebScraper only parses pages it fetches.
So the tests serve TestData/ from a small TcpListener server on a free localhost port.
None of them calls port 5461.

Together, the tests cover these cases:

- catalog-page-1.html yields 10 products, the first being LK-1001
- LK-1045 on catalog-page-5.html has the price 1249.00
- a crawl where one page answers 503 and the rest answer 200 writes no snapshot
- comparing two small snapshot files finds each change type once

TestData/ holds only pages 1 and 5 of the catalogue.
The 503 case can serve a small made-up catalogue, so the 503 is the only failure.

Use dotnet test --logger trx --results-directory out/tests/.
Read the pass and fail counts from the trx file and tell me both.
Text

最後のプロンプトはIronWebScraper.xmlのメンバーをプローブとテスト結果に対して確認します。XMLはScrapeUniqueが重複を無視するように説明し、最初のレコードが失われることについて何も言及していません。

$ironwebscraper Find the IronWebScraper.xml members that pace, retry, filter or save a crawl.
For each member, give me these two things:

- the XML's own description of it
- whether out/crawl-probe.csv or a test result under out/tests/ covers it

Then write a line that compiles for each member, in a project at scratch/api-probe/.
Build it with dotnet build scratch/api-probe, and don't run it.
Text

これらのプロンプトを別のカタログで再利用する方法

プロンプトはこのカタログのセレクター、製品コード、およびテストページを命名します。 これらをサプライヤの価格表、市場のカテゴリ、または社内製品フィードで再利用するには、開始ページ、セレクター、およびData/README.mdのスナップショット列と共にそれらの名前を置き換えます。 すべてのアシスタントに適用されるセットアップについては、IronWebScraper AIコーディングアシスタントガイドを参照してください。

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

上記のプロンプトは、1回のセッションで、localhostのテストカタログに対してCodexに送信されました。比較プロンプトの前に、サイトは2晩目の価格に切り替わりました。 レガシージョブ、そのログおよびその警告はデバッグプロンプトの前に追加されました。 別々のスクリプトがすべての出力ファイルとテストサイトのリクエストログを読みます。

  • 開始時、リポジトリにはパッケージのないコンソールプロジェクト、カタログルール、および2つの保存されたカタログページがありました。
  • 変数がクリアされ、Startup呼び出しがスキップされた状態で、クロールはライセンス例外を投げ、製品行を書き出しませんでした。
  • プローブで、ScrapeUniqueは10の個別の行のために9行を書き、LK-1001が欠落していました。
  • 最初のスナップショットには5ページすべての47製品が含まれていました。
  • 両方のスナップショットのすべてのフィールドがカタログと一致していました。
  • 変更レポートには3つの価格低下、3つの価格上昇、2つの新製品、1つの削除、および1つのストック変更がリストされていました。
  • ページ3が失敗した状態で、クローラーはコード2で終了し、スナップショットを保存しませんでした。
  • IronWebScraperからのカタログリクエストは少なくとも1,037ミリ秒間隔で行われていました。
  • 実行中の93のリクエストのうち、どれもカートやアカウントページに行きませんでした。
  • Codexはスクリーンショットを最初の夜のスナップショットと一致させました。
  • Codexはテントの現在の価格を$259.00として示しました。
  • 診断は4つの苦情それぞれをレガシージョブ内のそのラインに結びつけました。
  • Codexはそれぞれの4つのプロンプトでエクスプローラーまたはワーカーエージェントを名指しで別のエージェントを開始しました。
  • サービスは2番目のスナップショットをバイト単位で再構築しました。
  • 503テストは2ページからなる架空のカタログを提供し、その2ページ目が503で返答しました。
  • すべての4つのテストはCodexの最終ランと私たちのランで合格しました。
  • 一部のステップはページと異なる方法で実行されました。 最初の完全なテストランは4つのテストのうち1つが失敗し、CodexがそのテストのCSV解析を修正しました。 テストコマンドがスタックした間、Codexは設定された時間以後に開始されたすべての.NETプロセスを強制停止しました、どのプログラムがそれらを開始したかにかかわらず。 NuGetパッケージは実行の前に復元されたキャッシュから来たものです。なぜならサンドボックスにnuget.orgへのアクセスがなかったからです。

Google Antigravityガイドもクローリング出力をブラウザで人が見るページと対照することを確認します。 Claude CodeガイドもブログアーカイブクロールにおいてIronWebScraperが失敗するページをどのように削除するかを測定します。 共用ラン記録はこのランのためのCodexバージョン、モデル、テストマシン、およびタイミングをリストします。


トラブルシューティング


質問ありますか?

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

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

もっと読む

準備はできましたか?

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