IronWebScraperをGitHub Copilotで使用する方法

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

シネマ上映情報アグリゲーターは、複数の施設の上映スケジュールを一つのファイルに集約し、毎晩リスティングアプリがそれを読み取ります。 各施設は自らのページにプログラムを公開し、同じ映画が同時に3つの施設で上映されることがあります。 クロールが見逃した上映はアプリに全く表示されません。

GitHub Copilotは、Visual StudioやVS Codeでのチャットやエージェントモードを通じて、またターミナルでのCopilot CLIを通じてリポジトリと連携します。 GitHub上のそのクラウドエージェントは、割り当てられた課題をプルリクエストに変換します。IronWebScraperは.NETからWebScraperをサブクラス化し、InitとParseをオーバーライドしてウェブサイトをクロールします。 リポジトリにコミットされた指示ファイルは、クロウラーのルールを各サーフェスに伝えます。

このガイドは、Copilotを使用してクロウラーを構築および維持する方法を説明します。 映画ウェブサイトガイドには、クロウラーが従うリスティングページ、詳細ページ、MetaDataパターンが説明されています。 ここで説明するすべてのクロールは、常にローカルマシンで提供されるテストサイトを対象としており、シネマのライブウェブサイトを対象としていません。

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

PM > Install-Package IronWebScraper

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

リポジトリーのルートでターミナルを開き、Copilot CLIを開始してプロンプトを送信します。 @ はCopilot CLIで名前付きファイルを添付し、Visual StudioのCopilot Chatでは#参照を取ります。

Build the showtimes crawler in @src/Showtimes.Scraper/ShowtimeScraper.cs.
It collects every screening from the cinema test site at http://localhost:5447/.
Directory.Packages.props already pins IronWebScraper 2026.10.1.

The crawler should do this:
- Start at the site's start page and follow each venue's pages, page 2 included.
- Write one line per screening to out/showtimes.jsonl, using the Screening class.
- Fill the venue-page fields as @docs/output-format.md describes.
- Leave the film-page fields empty for now.

Then do these steps in order:
1. Add a crawl command to @src/Showtimes.Cli/Program.cs that takes --site <url> and --out <path>.
2. Run dotnet build.
3. In the repo root, run crawl --site http://localhost:5447/ --out out/showtimes.jsonl.

Tell me how many screenings each venue has.
Text

プロンプトではセレクタの名前を示しません。なぜなら、docs/output-format.mdに各フィールドのソース要素が一覧されているからです。

Copilotが実行される環境にIRONWEBSCRAPER_LICENSE_KEYを設定し、プログラムがそれをLicense.LicenseKeyにコピーするようにしてください。 ハブガイドには、IronWebScraperが自動的に読み取る変数が記載され、ライセンスキーガイドには他にサポートされる場所がリストされています。



IronWebScraperのコブピクッと用コンベンションをどう設定しますか?

プロジェクト全体のルールは.github/copilot-instructions.mdに配置します。 GitHubのサポートリファレンスは、このファイルをVisual Studio、VS Code、およびJetBrains IDEのCopilot Chat、そしてクラウドエージェントおよびCopilotコードレビューのためにリストしています。 Copilot CLIも同じ場所からこれを読み取ります。

This repo holds the showtimes crawler, which gathers cinema screenings into one file.
Follow these rules in every change:
- Use IronWebScraper for all crawling and HTML parsing, never HttpClient.
- Don't add AngleSharp, HtmlAgilityPack or another scraping package.
- Change the IronWebScraper version in Directory.Packages.props only in an upgrade task.
- The showtimes crawler and its tests read IRONWEBSCRAPER_LICENSE_KEY into License.LicenseKey.
- IronWebScraper won't read that variable name on its own, so set the key before Start.
- Keep the key out of all output, logs included.
- Don't list environment variables.
- Crawl only the site a task names, which is http://localhost:5447/ in development.
- Tests crawl TestData/site through a local HTTP listener and never touch that address.
- Keep RateLimitPerHost at one second.
- Write records with WebScraper.Scrape, not with a JSON writer of your own.
- Treat docs/output-format.md as the contract for out/showtimes.jsonl.
- If the contract looks wrong, tell me and leave the file alone.
- Read the IronWebScraper docs for agents at https://ironsoftware.com/webscraper/csharp/llms.txt
Markdown

レート制限ルールは、各クロールでリクエスト間の間隔を設定します。 デフォルトのRateLimitPerHostである50ミリ秒では、一つのプローブクロールでテストサイトに0.048から0.064秒間隔でリクエストが送信されました。 1秒では、ギャップは1.02から1.10秒と測定されました。

クロウラーに独自のルールをどのように提供しますか?

.github/instructions/scraper.instructions.mdのようなファイルは、そのapplyToパターンが名指ししたツリーの部分、ここではクロウラーとそのテストのためのルールを含みます。 GitHubのドキュメントによれば、Copilot CLIはこれらのパターンの1つと一致するファイルで作業している時にのみファイルを含めます。

---
applyTo: "src/**/*,tests/**/*"
---

The crawler and its tests rely on IronWebScraper 2026.10.1, which behaves like this:
- A crawl fetches each URL once per parse method.
- A second Request for that URL with the same parse method is dropped, even with new MetaData.
- MetaData passes the parse method the same object instance, not a copy.
- When a parse method throws, the page is fetched and parsed again, up to 8 more times.
- Each retry repeats every Scrape call made before the throw.
- A URL that answers 500 is requested 9 times, and its parse method is never called.
- Css throws an XPathException on a selector with two > combinators, such as div > p > a.
- TextContentClean returns entities such as &eacute; unchanged.

Follow these rules in this code:
- Request each film page once and copy its details onto every screening of that film.
- Decode text from TextContentClean with WebUtility.HtmlDecode.
Markdown

ファイルに記載された各ビヘイビアは、テストサイトに対するプローブから来ています。

IronWebScraperは3つの会場がリンクした映画ページをどう扱いますか?

会場ページは各映画を一つの映画ページにリンクし、ハーバーライツを上映する3つの会場は同じURLにリンクします。

Fill in the film-page fields on every line the crawler writes.
They are RuntimeMinutes, Genres and Rating, and @docs/output-format.md gives the source of each.
Follow this guide for the detail requests:
https://ironsoftware.com/webscraper/csharp/how-to/scraping-from-an-online-movie-website/

Two things about the test site matter here:
- Harbour Lights plays at all three venues, and all 6 of its screenings need the runtime.
- The Night Train to Arles page answers 500 on purpose.

Keep the Night Train to Arles screening, with its film fields empty.
Then run the crawl again with --out out/details/showtimes.jsonl.
Tell me how many lines got a runtime, and which film's lines didn't.
Text

IronWebScraperは、全体のクロールで一つのparseメソッドあたり一度だけURLを取得します。 プローブにおいて、3つの会場が同じparseメソッドでハーバーライツページをリクエストし異なるMetaDataを使い、サイトは1つのリクエストを受信しました。parseメソッドは最初の会場のMetaDataしか見なかったので、他の2つの会場の上映には詳細が届きませんでした。 異なるparseメソッドでリクエストされた同じURLは再度取得され、異なるクエリ文字列のページも同様でした。

映画ガイドの詳細パーサーは、ガイド自身のマークアップで失敗します。そのジャンルセレクターdiv > p > aと俳優セレクターdiv > p:nth-child(2) > aは共にXPathExceptionを投げました。なぜなら、IronWebScraperは2つの子コンビネーターを持つセレクターを拒否するからです。 一つのコンビネーターを持つセレクター、div.mvici-left > pのようなものは動作します。

IronWebScraperは、parseメソッドがスローしたページをリトライします。その際、ロードに失敗したページもリトライします。 プローブにおいて、9回のparseメソッド呼び出しが1ページに対して行われ、スロー前に行われたScrape呼び出しは9行を書き込んでいました。

出力

ブラウザでは、Riverside会場ページはアクセント付きの文字でその名前を表示しています。 ページソースはその文字を名前付きHTMLエンティティとして書き込み、TextContentCleanはエンティティをそのまま返しました。

ローカルテストサイトのRiverside会場ページに3つの映画とそれらの上映時間があります

Microsoft Edgeでキャプチャされた、ローカルテストサイトのRiverside会場のページ1。サイト上の全ての映画と会場は架空のものです。

Harbour Lightsが3つの会場で、Night Train to Arlesが空の映画フィールドであるshowtimes JSONLファイルの7行

Harbour LightsとNight Train to Arlesのアウトプットdetails/showtimes.jsonlの行が、ファイル内の行番号と共に第2プロンプトで書かれました。

ライブサイトを使用せずにクロウラーをテストする方法

Shift+Tabを使用してCopilot CLIを計画モードにサイクルし、このプロンプトを送信します。

Plan a new xUnit project, tests/Showtimes.Tests, listed in Showtimes.slnx.
Show me the plan, and don't write code until I say go.

The tests' local listener must answer 500 for /film/night-train-to-arles-20790/, like the test site.

Each test runs ShowtimeScraper and checks one of these:
- Northgate Picturehouse has 10 screenings, and the other two venues have 7 each.
- The Riverside venue name has no HTML entity left in it.
- All 6 Harbour Lights screenings have a RuntimeMinutes of 112.
- The Night Train to Arles screening is still there, with a null RuntimeMinutes.

After my go, write the tests and rerun dotnet test until every one passes.
Then give me the number that pass.
Text

TestData/siteのrobots.txtはテストクロールには影響しません。 IronWebScraperは開始URLのポートなしでrobots.txtをリクエストするため、ランダムなポートのリスナーがそれらのルールを提供することはありません。 ポート80のリスナーでは、プローブクロールがそれらを読み、許可されていない/予約/ページをスキップしました。 Claude Codeガイドはこの動作を完全にカバーしています。

なぜ一部の実行で会場が消えるのですか?

このシナリオでは、チームメイトのtools/VenueCheckが夜のクロールの前に3つの会場ページを要求し、応答しない会場を報告します。

tools/VenueCheck reports a venue as DOWN on some runs, though the site is up.
It checks the three venue pages listed in tools/VenueCheck/venues.json.
Find out why and fix it.

Before you fix anything, do these steps in order:
1. Run it five times against http://localhost:5447/ and note which venues came back DOWN.
2. Turn on LogLevel.All and find out what IronWebScraper does with the Request calls in Init.
3. Tell me the cause.

Keep the fix within these limits:
- Change files in tools/VenueCheck only.
- Add no sleep, and keep a single call to Start.

Then run it five more times and show me the results.
Text

IronWebScraperはInitで行われたいかなるリクエストも保持しません。 Initから3つの会場URLをリクエストし、26回のプローブランのうち1回で3つすべてをフェッチし、他の25回では1つまたは2つをフェッチしました。これらの26回の実行は、修正前にコミットされたプローブクロウラーの18回の実行とtools/VenueCheckの8回の実行を組み合わせています。 ログには3つのリクエストがリストされ、2つの後にクロール完了が報告され、スキップされたURLはサーバーに届きませんでした。 parseメソッドからなされたリクエストは失われませんでした。Initからの最初の会場をリクエストし、そのparseメソッドから他の2つをリクエストし、8回の実行中8回すべての会場が返されました。

クラウドエージェントが行動できる問題を作成するにはどうすれば良いですか?

GitHubによると、Copilotに割り当てられたイシューはエージェントにそのタイトル、説明、割り当て時のコメント、およびその時点で与えられた指示を渡します。 その後に追加されたコメントはエージェントに到達しないため、イシュー本体に全体のリクエストを保持する必要があります。

Title: A second crawl must not double out/showtimes.jsonl

Files: src/Showtimes.Scraper and tests/Showtimes.Tests
Versions: net9.0 with IronWebScraper 2026.10.1

Background: IronWebScraper's Scrape appends to the file it writes and never empties it.
Without a cleanup step, a second crawl to the same --out path leaves 48 lines instead of 24.

Expected: after any crawl, the output file holds exactly one line per screening.

Constraint: the crawl command keeps its options.

Acceptance: close the issue once these are true:
- Two crawls in a row leave the same 24 lines, in any order.
- A new test crawls twice into one temp folder and counts the lines.
- dotnet test passes.

Summary: say where the old output gets cleared, and why there.
Markdown

なぜクラウドエージェントのテストがIronWebScraperプロジェクトで失敗するのですか?

クロールに必要なテストはクラウドエージェントの環境にライセンスキーを必要とします。 GitHubのドキュメントはその環境をデフォルトでUbuntu Linuxと説明しており、.github/workflows/copilot-setup-steps.ymlのcopilot-setup-stepsジョブがそれを準備できます。 ジョブはCopilotが作動を開始する前にGitHub Actionsで実行され、ワークフローはファイルがデフォルトブランチにない限りトリガーされません。 セットアップステップが失敗した場合、Copilotは残りのセットアップステップをスキップし、現状の環境で動作を開始します。

Create the cloud agent's setup workflow in .github/workflows/copilot-setup-steps.yml.
Call its job copilot-setup-steps, because GitHub skips a job with any other name.

The job needs these settings:
- The runner is ubuntu-latest.
- The workflow token has contents: read and nothing else.
- workflow_dispatch triggers it, and so does a pull request that edits the file.

Its steps go in this order:
1. Check out the code.
2. Install .NET 9.
3. Run dotnet restore, then dotnet build -c Release.
4. Look for the license key.

The key is IRONWEBSCRAPER_LICENSE_KEY, saved as an Agents secret.
The job gets it as an environment variable already, so skip the secrets context.

When the key is missing, the last step behaves like this:
- On pull_request or workflow_dispatch, it logs a warning and passes.
- On any other event, it fails with an error naming the secret.

Show me the finished YAML, and don't try to run the workflow.
Text

キーをAgentsの秘密として保存します: GitHubによると、クラウドエージェントはActions、Codespaces、またはDependabotの秘密にアクセスできません。 リポジトリの設定で、セキュリティセクションの機密と変数を開き、Agentsを選択し、秘密タブでIRONWEBSCRAPER_LICENSE_KEYを追加します。 GitHubは、これらの秘密が「環境変数としてCopilotに公開されている」としており、Copilotが実行するスクリプトやツール、「あなたのcopilot-setup-steps.ymlワークフローを含む」によって使用できるとしています。ドキュメントは、可能性プロンプトで仮定されているenvマッピングなしでワークフローステップがそれを読むことができるとは述べていません。

マージする前に何を確認すべきですか?

コードを書いたセッションの外にある別のcopilot -pコマンドとしてレビューを実行します。

/review the changes on this branch compared with main.

Check the code against these three files:
- .github/copilot-instructions.md
- .github/instructions/scraper.instructions.md
- IronWebScraper.xml in the IronWebScraper package of the NuGet cache

Also look for two patterns that neither instructions file covers:
- an Init method that calls Request more than once
- a crawl that starts with an old output file still in place

List every mismatch you find, or say that nothing came up.
Don't change any file.
Text

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

7つのプロンプトはガイド用に構築されたショータイムリポジトリとローカルテストサイトに対するCopilot CLIで無人で実行されました。以下の全ての数字は、アウトプットファイル、サイトのリクエストログ、リポジトリから来たものであり、Copilotの返信から来たものではありません。

  • 実行前、CLIは使用法ラインを印刷し、コード1で終了しました。
  • 最初のプロンプトの後、out/showtimes.jsonlには24の上映があり、Northgate Picturehouseで10、他の2つの会場でそれぞれ7の上映が記録されていました。
  • 第2プロンプトのクロールでは、Night Train to Arlesを除く各映画ページが1リクエストを受け、これは9回のリクエストを受けたが、すべて500で応じました。
  • 第2プロンプトのファイルには24行があり、そのうち23行は実行時間を持っていました。
  • Night Train to Arlesの上映は、空の実行時間、ジャンルリスト、評価で残されました。
  • 3つの会場ですべての6つのHarbour Lightsの上映は112分の実行時間を持っていました。
  • 計画モードでは、Copilotは計画を書き、ファイルを変更せずに承認メッセージを待機しました。
  • 第3プロンプトの4つのテストはテストサイトに対する単一のリクエストなしで合格しました。
  • 修正前は、VenueCheckは5回のチェック実行のうち4回で1つまたは2つの会場をダウンとして報告しました。
  • 修正は、Initに1つのRequest呼び出しを残し、次の会場をparseメソッドからリクエストしました。
  • 3 つの環境すべてが、固定チェックの 10 回の実行で 10 回とも応答しました。
  • 最初の会場が500で応答した場合、修正されたVenueCheckは3回の実行すべてで全3会場をダウンとして報告しました。
  • その実行では他の2つの会場ページに対してリクエストは送信されませんでした。
  • イシューセッションは新しいテストを追加し、最初のプロンプト以来古いアウトプットを削除したため、クロウラーは変更されませんでした。
  • 最終リポジトリの全5つのテストはキーが設定されている場合に合格し、設定されていない場合に失敗しました。
  • レビューセッションは不一致を報告せず、ファイルを変更しませんでした。それが検索したどちらのパターンも以前のプロンプト後に残っていなかったため、この実行はレビューがそれらを見つけるかどうかをテストしませんでした。
  • 一部のステップはページと異なる方法で実行されました。 イシューの本文はテストリポジトリにはGitHubリモートがないため新しいCopilot CLIのセッションに送られました。 設定ワークフローは書き込まれましたが、同じ理由で実行されませんでした。

カーソルは、コミットされたルールを名前のパスにスコープし、Claude Codeもプロジェクトを編集する前に承認のための計画を保持します。 共用の実行記録には、Copilot CLIのリリース、モデルのオート選択、持続時間、テスト機材がリストされています。


トラブルシューティング


質問ありますか?

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

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

もっと読む

準備はできましたか?

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