IronWebScraper チュートリアル 高度なWebスクレイピング機能 C# の高度な Web スクレイピング機能 カーティス・チャウ 更新日:6月 9, 2025 IronWebScraper をダウンロード NuGet ダウンロード DLL ダウンロード 無料トライアル LLM向けのコピー LLM向けのコピー LLM 用の Markdown としてページをコピーする ChatGPTで開く このページについてChatGPTに質問する ジェミニで開く このページについてGeminiに問い合わせる ジェミニで開く このページについてGeminiに問い合わせる 困惑の中で開く このページについてPerplexityに問い合わせる 共有する Facebook で共有 Xでシェア(Twitter) LinkedIn で共有 URLをコピー 記事をメールで送る This article was translated from English: Does it need improvement? Translated View the article in English HttpIdentity 機能 一部のウェブサイトシステムでは、コンテンツを表示するためにユーザーがログインしている必要があります; この場合、HttpIdentityを使用できます。 設定方法は次の通りです: // Create a new instance of HttpIdentity HttpIdentity id = new HttpIdentity(); // Set the network username and password for authentication id.NetworkUsername = "username"; id.NetworkPassword = "pwd"; // Add the identity to the collection of identities Identities.Add(id); // Create a new instance of HttpIdentity HttpIdentity id = new HttpIdentity(); // Set the network username and password for authentication id.NetworkUsername = "username"; id.NetworkPassword = "pwd"; // Add the identity to the collection of identities Identities.Add(id); ' Create a new instance of HttpIdentity Dim id As New HttpIdentity() ' Set the network username and password for authentication id.NetworkUsername = "username" id.NetworkPassword = "pwd" ' Add the identity to the collection of identities Identities.Add(id) $vbLabelText $csharpLabel IronWebScraper の最も印象的で強力な機能の1つは、何千ものユニークなユーザー資格情報やブラウザエンジンを使用して、複数のログインセッションを通じてウェブサイトをスプーフィングまたはスクレイピングする能力です。 public override void Init() { // Set the license key for IronWebScraper License.LicenseKey = "LicenseKey"; // Set the logging level to capture all logs this.LoggingLevel = WebScraper.LogLevel.All; // Assign the working directory for the output files this.WorkingDirectory = AppSetting.GetAppRoot() + @"\ShoppingSiteSample\Output\"; // Define an array of proxies var proxies = "IP-Proxy1:8080,IP-Proxy2:8081".Split(','); // Iterate over common Chrome desktop user agents foreach (var UA in IronWebScraper.CommonUserAgents.ChromeDesktopUserAgents) { // Iterate over the proxies foreach (var proxy in proxies) { // Add a new HTTP identity with specific user agent and proxy Identities.Add(new HttpIdentity() { UserAgent = UA, UseCookies = true, Proxy = proxy }); } } // Make an initial request to the website with a parse method this.Request("http://www.Website.com", Parse); } public override void Init() { // Set the license key for IronWebScraper License.LicenseKey = "LicenseKey"; // Set the logging level to capture all logs this.LoggingLevel = WebScraper.LogLevel.All; // Assign the working directory for the output files this.WorkingDirectory = AppSetting.GetAppRoot() + @"\ShoppingSiteSample\Output\"; // Define an array of proxies var proxies = "IP-Proxy1:8080,IP-Proxy2:8081".Split(','); // Iterate over common Chrome desktop user agents foreach (var UA in IronWebScraper.CommonUserAgents.ChromeDesktopUserAgents) { // Iterate over the proxies foreach (var proxy in proxies) { // Add a new HTTP identity with specific user agent and proxy Identities.Add(new HttpIdentity() { UserAgent = UA, UseCookies = true, Proxy = proxy }); } } // Make an initial request to the website with a parse method this.Request("http://www.Website.com", Parse); } Public Overrides Sub Init() ' Set the license key for IronWebScraper License.LicenseKey = "LicenseKey" ' Set the logging level to capture all logs Me.LoggingLevel = WebScraper.LogLevel.All ' Assign the working directory for the output files Me.WorkingDirectory = AppSetting.GetAppRoot() & "\ShoppingSiteSample\Output\" ' Define an array of proxies Dim proxies = "IP-Proxy1:8080,IP-Proxy2:8081".Split(","c) ' Iterate over common Chrome desktop user agents For Each UA In IronWebScraper.CommonUserAgents.ChromeDesktopUserAgents ' Iterate over the proxies For Each proxy In proxies ' Add a new HTTP identity with specific user agent and proxy Identities.Add(New HttpIdentity() With { .UserAgent = UA, .UseCookies = True, .Proxy = proxy }) Next proxy Next UA ' Make an initial request to the website with a parse method Me.Request("http://www.Website.com", Parse) End Sub $vbLabelText $csharpLabel さまざまな動作を提供する複数のプロパティを持っているため、ウェブサイトがブロックするのを防ぎます。 これらのプロパティには以下が含まれます: NetworkDomain: ユーザー認証に使用するネットワークドメイン。 Windows、NTLM、Kerberos、Linux、BSD、および Mac OS X ネットワークをサポートしています。 NetworkUsername と NetworkPassword と共に使用しなければなりません。 NetworkUsername: ユーザー認証に使用するネットワーク/http ユーザー名。 HTTP、Windows ネットワーク、NTLM、Kerberos、Linux ネットワーク、BSD ネットワーク、および Mac OS をサポートしています。 NetworkPassword: ユーザー認証に使用するネットワーク/http パスワード。 HTTP、Windows ネットワーク、NTLM、Kerberos、Linux ネットワーク、BSD ネットワーク、および Mac OS をサポートしています。 Proxy: プロキシ設定。 UserAgent: ブラウザエンジンの設定(例:Chrome デスクトップ、Chrome モバイル、Chrome タブレット、IE、および Firefox など)。 HttpRequestHeaders: このアイデンティティに使用されるカスタムヘッダー値を指定するため、Dictionary<string, string> オブジェクトを受け入れます。 UseCookies: クッキーの使用を有効/無効にします。 IronWebScraper はランダムなアイデンティティでスクレイパーを実行します。 特定のアイデンティティを指定してページを解析する必要がある場合、以下を行うことができます: public override void Init() { // Set the license key for IronWebScraper License.LicenseKey = "LicenseKey"; // Set the logging level to capture all logs this.LoggingLevel = WebScraper.LogLevel.All; // Assign the working directory for the output files this.WorkingDirectory = AppSetting.GetAppRoot() + @"\ShoppingSiteSample\Output\"; // Create a new instance of HttpIdentity HttpIdentity identity = new HttpIdentity(); // Set the network username and password for authentication identity.NetworkUsername = "username"; identity.NetworkPassword = "pwd"; // Add the identity to the collection of identities Identities.Add(identity); // Make a request to the website with the specified identity this.Request("http://www.Website.com", Parse, identity); } public override void Init() { // Set the license key for IronWebScraper License.LicenseKey = "LicenseKey"; // Set the logging level to capture all logs this.LoggingLevel = WebScraper.LogLevel.All; // Assign the working directory for the output files this.WorkingDirectory = AppSetting.GetAppRoot() + @"\ShoppingSiteSample\Output\"; // Create a new instance of HttpIdentity HttpIdentity identity = new HttpIdentity(); // Set the network username and password for authentication identity.NetworkUsername = "username"; identity.NetworkPassword = "pwd"; // Add the identity to the collection of identities Identities.Add(identity); // Make a request to the website with the specified identity this.Request("http://www.Website.com", Parse, identity); } Public Overrides Sub Init() ' Set the license key for IronWebScraper License.LicenseKey = "LicenseKey" ' Set the logging level to capture all logs Me.LoggingLevel = WebScraper.LogLevel.All ' Assign the working directory for the output files Me.WorkingDirectory = AppSetting.GetAppRoot() & "\ShoppingSiteSample\Output\" ' Create a new instance of HttpIdentity Dim identity As New HttpIdentity() ' Set the network username and password for authentication identity.NetworkUsername = "username" identity.NetworkPassword = "pwd" ' Add the identity to the collection of identities Identities.Add(identity) ' Make a request to the website with the specified identity Me.Request("http://www.Website.com", Parse, identity) End Sub $vbLabelText $csharpLabel ウェブキャッシュ機能の有効化 この機能は要求されたページをキャッシュするために使用されます。 開発とテストの段階でしばしば使用され、開発者がコードを更新した後に必要なページを再利用できるようにキャッシュします。 これにより、ウェブスクレイパーを再起動した後、常にライブウェブサイトに接続する必要なく、キャッシュされたページ上でコードを実行できます(アクションリプレイ)。 Init() メソッドで使用できます: // Enable web cache without an expiration time EnableWebCache(); // OR enable web cache with a specified expiration time EnableWebCache(new TimeSpan(1, 30, 30)); // Enable web cache without an expiration time EnableWebCache(); // OR enable web cache with a specified expiration time EnableWebCache(new TimeSpan(1, 30, 30)); ' Enable web cache without an expiration time EnableWebCache() ' OR enable web cache with a specified expiration time EnableWebCache(New TimeSpan(1, 30, 30)) $vbLabelText $csharpLabel 作業ディレクトリフォルダの下の WebCache フォルダにキャッシュデータを保存します。 public override void Init() { // Set the license key for IronWebScraper License.LicenseKey = "LicenseKey"; // Set the logging level to capture all logs this.LoggingLevel = WebScraper.LogLevel.All; // Assign the working directory for the output files this.WorkingDirectory = AppSetting.GetAppRoot() + @"\ShoppingSiteSample\Output\"; // Enable web cache with a specific expiration time of 1 hour, 30 minutes, and 30 seconds EnableWebCache(new TimeSpan(1, 30, 30)); // Make an initial request to the website with a parse method this.Request("http://www.Website.com", Parse); } public override void Init() { // Set the license key for IronWebScraper License.LicenseKey = "LicenseKey"; // Set the logging level to capture all logs this.LoggingLevel = WebScraper.LogLevel.All; // Assign the working directory for the output files this.WorkingDirectory = AppSetting.GetAppRoot() + @"\ShoppingSiteSample\Output\"; // Enable web cache with a specific expiration time of 1 hour, 30 minutes, and 30 seconds EnableWebCache(new TimeSpan(1, 30, 30)); // Make an initial request to the website with a parse method this.Request("http://www.Website.com", Parse); } Public Overrides Sub Init() ' Set the license key for IronWebScraper License.LicenseKey = "LicenseKey" ' Set the logging level to capture all logs Me.LoggingLevel = WebScraper.LogLevel.All ' Assign the working directory for the output files Me.WorkingDirectory = AppSetting.GetAppRoot() & "\ShoppingSiteSample\Output\" ' Enable web cache with a specific expiration time of 1 hour, 30 minutes, and 30 seconds EnableWebCache(New TimeSpan(1, 30, 30)) ' Make an initial request to the website with a parse method Me.Request("http://www.Website.com", Parse) End Sub $vbLabelText $csharpLabel IronWebScraper には、コードを再起動した後でもスクレイピングを続けるための機能があり、Start(CrawlID) を使用してエンジン開始プロセス名を設定することができます。 static void Main(string[] args) { // Create an object from the Scraper class EngineScraper scrape = new EngineScraper(); // Start the scraping process with the specified crawl ID scrape.Start("enginestate"); } static void Main(string[] args) { // Create an object from the Scraper class EngineScraper scrape = new EngineScraper(); // Start the scraping process with the specified crawl ID scrape.Start("enginestate"); } Shared Sub Main(ByVal args() As String) ' Create an object from the Scraper class Dim scrape As New EngineScraper() ' Start the scraping process with the specified crawl ID scrape.Start("enginestate") End Sub $vbLabelText $csharpLabel 実行リクエストとレスポンスは、作業ディレクトリ内の SavedState フォルダに保存されます。 スロットリング ドメインごとの最小および最大接続数および接続速度を制御できます。 public override void Init() { // Set the license key for IronWebScraper License.LicenseKey = "LicenseKey"; // Set the logging level to capture all logs this.LoggingLevel = WebScraper.LogLevel.All; // Assign the working directory for the output files this.WorkingDirectory = AppSetting.GetAppRoot() + @"\ShoppingSiteSample\Output\"; // Set the total number of allowed open HTTP requests (threads) this.MaxHttpConnectionLimit = 80; // Set minimum polite delay (pause) between requests to a given domain or IP address this.RateLimitPerHost = TimeSpan.FromMilliseconds(50); // Set the allowed number of concurrent HTTP requests (threads) per hostname or IP address this.OpenConnectionLimitPerHost = 25; // Do not obey the robots.txt files this.ObeyRobotsDotTxt = false; // Makes the WebScraper intelligently throttle requests not only by hostname, but also by host servers' IP addresses this.ThrottleMode = Throttle.ByDomainHostName; // Make an initial request to the website with a parse method this.Request("https://www.Website.com", Parse); } public override void Init() { // Set the license key for IronWebScraper License.LicenseKey = "LicenseKey"; // Set the logging level to capture all logs this.LoggingLevel = WebScraper.LogLevel.All; // Assign the working directory for the output files this.WorkingDirectory = AppSetting.GetAppRoot() + @"\ShoppingSiteSample\Output\"; // Set the total number of allowed open HTTP requests (threads) this.MaxHttpConnectionLimit = 80; // Set minimum polite delay (pause) between requests to a given domain or IP address this.RateLimitPerHost = TimeSpan.FromMilliseconds(50); // Set the allowed number of concurrent HTTP requests (threads) per hostname or IP address this.OpenConnectionLimitPerHost = 25; // Do not obey the robots.txt files this.ObeyRobotsDotTxt = false; // Makes the WebScraper intelligently throttle requests not only by hostname, but also by host servers' IP addresses this.ThrottleMode = Throttle.ByDomainHostName; // Make an initial request to the website with a parse method this.Request("https://www.Website.com", Parse); } Public Overrides Sub Init() ' Set the license key for IronWebScraper License.LicenseKey = "LicenseKey" ' Set the logging level to capture all logs Me.LoggingLevel = WebScraper.LogLevel.All ' Assign the working directory for the output files Me.WorkingDirectory = AppSetting.GetAppRoot() & "\ShoppingSiteSample\Output\" ' Set the total number of allowed open HTTP requests (threads) Me.MaxHttpConnectionLimit = 80 ' Set minimum polite delay (pause) between requests to a given domain or IP address Me.RateLimitPerHost = TimeSpan.FromMilliseconds(50) ' Set the allowed number of concurrent HTTP requests (threads) per hostname or IP address Me.OpenConnectionLimitPerHost = 25 ' Do not obey the robots.txt files Me.ObeyRobotsDotTxt = False ' Makes the WebScraper intelligently throttle requests not only by hostname, but also by host servers' IP addresses Me.ThrottleMode = Throttle.ByDomainHostName ' Make an initial request to the website with a parse method Me.Request("https://www.Website.com", Parse) End Sub $vbLabelText $csharpLabel スロットリングプロパティ MaxHttpConnectionLimit 許可されるオープンされた HTTP リクエスト(スレッド)の総数 RateLimitPerHost ドメインまたは IP アドレスに対するリクエスト間の最小の丁寧な遅延または一時停止(ミリ秒単位) OpenConnectionLimitPerHost ホスト名ごとに許可される同時 HTTP リクエスト(スレッド)の数 ThrottleMode WebScraper がホスト名だけでなく、ホストサーバーの IP アドレスによっても賢くリクエストを制限するようにします。 これは、同じマシンにホストされている複数のスクレイプされたドメインの場合には丁寧です。 IronWebscraperを使い始める 今日あなたのプロジェクトでIronWebScraperを無料トライアルで使用開始。 最初のステップ: 無料で始める よくある質問 C# でログインを要求する Web サイトのユーザーをどのように認証できますか? IronWebScraper の HttpIdentity 機能を利用して、NetworkDomain、NetworkUsername、および NetworkPassword などのプロパティを設定することでユーザーを認証できます。 開発中に Web キャッシュを使用する利点は何ですか? Web キャッシュ機能を使用すると、要求されたページを再利用のためにキャッシュでき、特に開発およびテストフェーズ中に反復接続を避けて時間とリソースを節約できます。 Web スクレイピングで複数のログインセッションを管理する方法は? IronWebScraper は、クラウドエンジンとともに、何千ものユニークなユーザー認証情報を使用して複数のログインセッションを模倣できるため、Web サイトから検出またはブロックされることを防ぎます。 Web スクレイピングにおける高度なスロットリングオプションは何ですか? IronWebScraper は、ホスト名と IP アドレスに基づいて要求スロットリングをインテリジェントに管理する ThrottleMode 設定を提供しており、共有ホスティング環境との礼儀正しいやり取りを確保します。 IronWebScraper とプロキシをどのように使用しますか? プロキシを使用するには、プロキシの配列を定義し、IronWebScraper の HttpIdentity インスタンスと関連付け、要求を異なる IP アドレス経由でルーティングして匿名性とアクセス制御を可能にします。 IronWebScraper はサーバーの過負荷を防ぐために要求の遅延をどのように処理しますか? IronWebScraper の RateLimitPerHost 設定は、特定のドメインまたは IP アドレスへの要求ごとに最小遅延を指定し、要求を間隔をあけることでサーバーの過負荷を防ぎます。 Web スクレイピングが中断された場合、再開できますか? はい、IronWebScraper は Start(CrawlID) メソッドを使用して再開でき、中断前の最後の状態から再開します。 Web スクレイパーでの同時 HTTP 接続の数をどのように制御しますか? IronWebScraper では MaxHttpConnectionLimit プロパティを設定して、許可されるオープン HTTP リクエストの合計数を制御し、サーバー負荷とリソースを管理します。 Web スクレイピング活動のログを記録するためのオプションは何ですか? IronWebScraperでは、LoggingLevelプロパティを使用してロギングレベルを設定でき、スクレイピング操作中の詳細分析とトラブルシューティングのための包括的なロギングを有効にします。 カーティス・チャウ 今すぐエンジニアリングチームとチャット テクニカルライター Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。 準備はできましたか? Nuget ダウンロード 125,527 | Version: 2025.11 リリース NuGet 無料版 総ダウンロード数: 125,527 ライセンスを見る