IRONSOFTWAREHOME

Advanced Webscraping Features in C#

Curtis Chau
Curtis Chau
Updated: 2026年6月29日

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);

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);
}

異なる動作を提供し、ウェブサイトがブロックするのを防ぐための複数のプロパティがあります。

これらのプロパティには以下が含まれます:

  • NetworkDomain: ユーザー認証に使用するネットワークドメイン。 Windows、NTLM、Kerberos、Linux、BSD、および Mac OS X ネットワークをサポートしています。 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);
}

ウェブキャッシュ機能の有効化

この機能は要求されたページをキャッシュするために使用されます。 開発とテストの段階でしばしば使用され、開発者がコードを更新した後に必要なページを再利用できるようにキャッシュします。 これにより、ウェブスクレイパーを再起動した後、常にライブウェブサイトに接続する必要なく、キャッシュされたページ上でコードを実行できます(アクションリプレイ)。

それをInit()メソッドで使用できます。

// Enable web cache without an expiration time
EnableWebCache();

// OR enable web cache with a specified expiration time
EnableWebCache(new TimeSpan(1, 30, 30));

キャッシュされたデータは、作業ディレクトリ内の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);
}

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");
}

実行リクエストとレスポンスは作業ディレクトリ内の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);
}

スロットリングプロパティ

  • MaxHttpConnectionLimit 許可されるオープンされた HTTP リクエスト(スレッド)の総数
  • RateLimitPerHost ドメインまたは IP アドレスに対するリクエスト間の最小の丁寧な遅延または一時停止(ミリ秒単位)
  • OpenConnectionLimitPerHost ホスト名ごとに許可される同時 HTTP リクエスト(スレッド)の数
  • ThrottleMode WebScraper がホスト名だけでなく、ホストサーバーの IP アドレスによっても賢くリクエストを制限するようにします。 これは、同じマシンにホストされている複数のスクレイプされたドメインの場合には丁寧です。

IronWebScraperで始めましょう

Start using IronWebScraper in your project today with a free trial.

最初のステップ:
arrow pointer

よくある質問

C# でログインを要求する Web サイトのユーザーをどのように認証できますか?

IronWebScraper の HttpIdentity 機能を利用して、NetworkDomainNetworkUsername、および 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プロパティを使用してロギングレベルを設定でき、スクレイピング操作中の詳細分析とトラブルシューティングのための包括的なロギングを有効にします。

Can IronWebScraper work without connecting to a live website constantly?

Yes, IronWebScraper can work by utilizing its web cache feature, which allows it to perform actions on cached pages without repeatedly connecting to the live website, thus facilitating faster testing and development cycles.

Curtis Chau
テクニカルライター

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

...
詳しく読む

準備はできましたか?

Nuget Downloads 143,929バージョン:2026.9リリースされたばかり

あなたの無料30日間の試用キーをすぐに入手。
クレジットカードやアカウントの作成は不要です。
PDF用C# NuGetライブラリ
NuGetでインストール

バージョン: 2026.9

PM > Install-Package IronWebScraper
nuget.org/packages/IronWebScraper/
  1. ソリューションエクスプローラーで参照を右クリックし、NuGetパッケージを管理を選択
  2. 『参照』を選択して「IronWebScraper」を検索します。
  3. パッケージを選択してインストール
C# PDF DLL
DLLをダウンロード

バージョン: 2026.9

  1. IronWebScraperを~/Libsなどのあなたのソリューションディレクトリ内の場所にダウンロードして解凍してください。
  2. Visual Studioのソリューションエクスプローラーで、『参照』を右クリックします。『参照』選択、「IronWebScraper.dll」

Licenses from $999

Key in blue circle

無料の30日間トライアルキーをすぐに入手してください。

Your trial license will be sent to your email address

制限なし。100% ロック解除済み。クレジットカード不要。

bullet_checkedクレジットカードやアカウントの作成は不要です。制限なし。100% ロック解除済み。クレジットカード不要。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
無料のライブデモを予約する
Booking Badge

世界中の数百万人のエンジニアから信頼されています。

ライセンスはより安く
義務のない相談を受ける
下記のフォームを記入するか、sales@ironsoftware.comにメールしてください。
あなたの詳細は常に守秘されます。
世界中の数百万人のエンジニアから信頼されています。
ライセンスはより安く
あなたの無料30日間の試用キーをすぐに入手。
クレジットカードやアカウントの作成は不要です。