---
product: Chilkat
product_version: 11.7.0
language: csharp
language_label: C#
class: Spider
license: free
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/csSpiderRef.html
---
# Chilkat Spider — C# — v11.7.0

> Chilkat 11.7.0 · language=csharp · class=Spider
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/Spider.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/csharp/guide.md`.

## Purpose

**Crawl a website domain, manage URL queues, filter links, cache pages, and inspect fetched HTML.**

`Chilkat.Spider` crawls pages within a single initialized domain. It maintains internal lists of unspidered, spidered, failed, and outbound URLs; fetches one page at a time; extracts same-domain links for continued crawling; collects outbound links separately; respects `robots.txt`; supports wildcard include and avoid patterns; can use a dedicated cache directory; and exposes the last fetched HTML, title, meta description, keywords, redirect information, cache status, and last-modified date.

**Domain-limited crawling**

Initialize the spider with a domain and crawl only URLs that belong to that same domain.

**URL queue management**

Add starting URLs, crawl the next queued URL, skip selected URLs, and inspect unspidered, spidered, failed, and outbound URL lists.

**Filtering rules**

Add wildcard avoid patterns, must-match patterns, and outbound-link avoid patterns to control which URLs are crawled or collected.

**Page metadata**

Read the last fetched HTML, page title, meta description, meta keywords, final redirect URL, and last-modified timestamp.

**Caching and redirects**

Fetch pages from a Chilkat-managed cache, update the cache, detect when a page was redirected, and inspect whether the last page came from cache.

**Network controls**

Configure user-agent, proxy settings, connect/read timeouts, IPv6 preference, maximum URL length, maximum response size, and abort support.

**Common pattern:** Call `Initialize` with the target domain, add one or more starting URLs with `AddUnspidered`, optionally add filtering patterns, then repeatedly call `CrawlNext`. After each successful crawl, inspect `LastUrl`, `LastHtml`, page metadata, redirect state, and the URL-list counts to decide whether to continue, skip, recrawl, or process the page.

**Scope note:** `Spider` is intended for controlled, domain-oriented crawling and link discovery. Use `Chilkat.Http` or `Chilkat.Rest` when the task is a single HTTP request, API call, form post, or download rather than a crawl of discovered links.

## Object creation, unlocking and error handling

**Object Creation**

```csharp
Chilkat.Spider obj = new Chilkat.Spider();
```

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in C#.

Minimal complete program:

```csharp
// Required once per process. Any string unlocks a 30-day trial; use your purchased code in production.
Chilkat.Global glob = new Chilkat.Global();
if (!glob.UnlockBundle("Anything for 30-day trial"))
{
    Console.WriteLine(glob.LastErrorText);
    return;
}

Chilkat.Spider spider = new Chilkat.Spider();
```

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `public string DebugLogFilePath {get; set; }` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastErrorHtml` | `public string LastErrorHtml {get; }` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `public string LastErrorText {get; }` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `public string LastErrorXml {get; }` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `public bool LastMethodSuccess {get; set; }` | read/write | Indicates the success or failure of the most recent method call: `true` means success, `false` means failure. |
| `VerboseLogging` | `public bool VerboseLogging {get; set; }` | read/write | If set to `true`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `public string Version {get; }` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `AbortCurrent` | property, read/write | `public bool AbortCurrent {get; set; }` |
| `AvoidHttps` | property, read/write | `public bool AvoidHttps {get; set; }` |
| `CacheDir` | property, read/write | `public string CacheDir {get; set; }` |
| `ChopAtQuery` | property, read/write | `public bool ChopAtQuery {get; set; }` |
| `ConnectTimeout` | property, read/write | `public int ConnectTimeout {get; set; }` |
| `Domain` | property, read-only | `public string Domain {get; }` |
| `FetchFromCache` | property, read/write | `public bool FetchFromCache {get; set; }` |
| `FinalRedirectUrl` | property, read-only | `public string FinalRedirectUrl {get; }` |
| `HeartbeatMs` | property, read/write | `public int HeartbeatMs {get; set; }` |
| `LastFromCache` | property, read-only | `public bool LastFromCache {get; }` |
| `LastHtml` | property, read-only | `public string LastHtml {get; }` |
| `LastHtmlDescription` | property, read-only | `public string LastHtmlDescription {get; }` |
| `LastHtmlKeywords` | property, read-only | `public string LastHtmlKeywords {get; }` |
| `LastHtmlTitle` | property, read-only | `public string LastHtmlTitle {get; }` |
| `LastModDateStr` | property, read-only | `public string LastModDateStr {get; }` |
| `LastUrl` | property, read-only | `public string LastUrl {get; }` |
| `MaxResponseSize` | property, read/write | `public int MaxResponseSize {get; set; }` |
| `MaxUrlLen` | property, read/write | `public int MaxUrlLen {get; set; }` |
| `NumAvoidPatterns` | property, read-only | `public int NumAvoidPatterns {get; }` |
| `NumFailed` | property, read-only | `public int NumFailed {get; }` |
| `NumOutboundLinks` | property, read-only | `public int NumOutboundLinks {get; }` |
| `NumSpidered` | property, read-only | `public int NumSpidered {get; }` |
| `NumUnspidered` | property, read-only | `public int NumUnspidered {get; }` |
| `PreferIpv6` | property, read/write | `public bool PreferIpv6 {get; set; }` |
| `ProxyDomain` | property, read/write | `public string ProxyDomain {get; set; }` |
| `ProxyLogin` | property, read/write | `public string ProxyLogin {get; set; }` |
| `ProxyPassword` | property, read/write | `public string ProxyPassword {get; set; }` |
| `ProxyPort` | property, read/write | `public int ProxyPort {get; set; }` |
| `ReadTimeout` | property, read/write | `public int ReadTimeout {get; set; }` |
| `UpdateCache` | property, read/write | `public bool UpdateCache {get; set; }` |
| `UserAgent` | property, read/write | `public string UserAgent {get; set; }` |
| `WasRedirected` | property, read-only | `public bool WasRedirected {get; }` |
| `WindDownCount` | property, read/write | `public int WindDownCount {get; set; }` |
| `AddAvoidOutboundLinkPattern` | method | `public void AddAvoidOutboundLinkPattern(string pattern);` |
| `AddAvoidPattern` | method | `public void AddAvoidPattern(string pattern);` |
| `AddMustMatchPattern` | method | `public void AddMustMatchPattern(string pattern);` |
| `AddUnspidered` | method | `public void AddUnspidered(string url);` |
| `CanonicalizeUrl` | method | `public string CanonicalizeUrl(string url);` |
| `ClearFailedUrls` | method | `public void ClearFailedUrls();` |
| `ClearOutboundLinks` | method | `public void ClearOutboundLinks();` |
| `ClearSpideredUrls` | method | `public void ClearSpideredUrls();` |
| `CrawlNext` | method | `public bool CrawlNext();` |
| `FetchRobotsText` | method | `public string FetchRobotsText();` |
| `GetAvoidPattern` | method | `public string GetAvoidPattern(int index);` |
| `GetBaseDomain` | method | `public string GetBaseDomain(string domain);` |
| `GetFailedUrl` | method | `public string GetFailedUrl(int index);` |
| `GetOutboundLink` | method | `public string GetOutboundLink(int index);` |
| `GetSpideredUrl` | method | `public string GetSpideredUrl(int index);` |
| `GetUnspideredUrl` | method | `public string GetUnspideredUrl(int index);` |
| `GetUrlDomain` | method | `public string GetUrlDomain(string url);` |
| `Initialize` | method | `public void Initialize(string domain);` |
| `LoadTaskCaller` | method | `public bool LoadTaskCaller(Task task);` |
| `RecrawlLast` | method | `public bool RecrawlLast();` |
| `SkipUnspidered` | method | `public void SkipUnspidered(int index);` |
| `SleepMs` | method | `public void SleepMs(int numMilliseconds);` |

## Properties

### Spider.AbortCurrent

`Chilkat 11.7.0 · csharp · Spider · AbortCurrent · property · read/write · since 9.5.0.58`

```csharp
public bool AbortCurrent {get; set; }
```

When set to `true`, causes the currently running method to abort. Methods that always finish quickly (i.e.have no length file operations or network communications) are not affected. If no method is running, then this property is automatically reset to `false` when the next method is called. When the abort occurs, this property is reset to `false`. Both synchronous and asynchronous method calls can be aborted. (A synchronous method call could be aborted by setting this property from a separate thread.)

### Spider.AvoidHttps

`Chilkat 11.7.0 · csharp · Spider · AvoidHttps · property · read/write`

```csharp
public bool AvoidHttps {get; set; }
```

If set the 1 (true) the spider will avoid all HTTPS URLs. The default is 0 (false).

### Spider.CacheDir

`Chilkat 11.7.0 · csharp · Spider · CacheDir · property · read/write`

```csharp
public string CacheDir {get; set; }
```

Specifies a cache directory to use for spidering. If either of the FetchFromCache or UpdateCache properties are true, this is the location of the cache to be used. Note: the Internet Explorer, Netscape, and FireFox caches are completely separate from the Chilkat Spider cache directory. You should specify a new and empty directory.

### Spider.ChopAtQuery

`Chilkat 11.7.0 · csharp · Spider · ChopAtQuery · property · read/write`

```csharp
public bool ChopAtQuery {get; set; }
```

If equal to 1 (true), then the query portion of all URLs are automatically removed when adding to the unspidered list. The default value is 0 (false).

### Spider.ConnectTimeout

`Chilkat 11.7.0 · csharp · Spider · ConnectTimeout · property · read/write`

```csharp
public int ConnectTimeout {get; set; }
```

The maximum number of seconds to wait while connecting to an HTTP server.

### Spider.Domain

`Chilkat 11.7.0 · csharp · Spider · Domain · property · read-only`

```csharp
public string Domain {get; }
```

The domain name that is being spidered. This is the domain previously set in the Initialize method.

### Spider.FetchFromCache

`Chilkat 11.7.0 · csharp · Spider · FetchFromCache · property · read/write`

```csharp
public bool FetchFromCache {get; set; }
```

If equal to 1 (true) then pages are fetched from cache when possible. If 0, the cache is ignored. The default value is 1. Regardless, if no CacheDir is set then the cache is not used.

### Spider.FinalRedirectUrl

`Chilkat 11.7.0 · csharp · Spider · FinalRedirectUrl · property · read-only · since 9.5.0.85`

```csharp
public string FinalRedirectUrl {get; }
```

If the last URL crawled was redirected (as indicated by the WasRedirected property), this property will contain the final redirect URL.

### Spider.HeartbeatMs

`Chilkat 11.7.0 · csharp · Spider · HeartbeatMs · property · read/write`

```csharp
public int HeartbeatMs {get; set; }
```

**Full documentation for this property (same in every language):** [Event Callback Examples](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/event_callback_examples.md)

The interval in milliseconds between each `AbortCheck` event callback, which enables an application to abort certain method calls before they complete. **By default, HeartbeatMs is set to** `0`**, meaning no AbortCheck event callbacks will trigger.**

### Spider.LastFromCache

`Chilkat 11.7.0 · csharp · Spider · LastFromCache · property · read-only`

```csharp
public bool LastFromCache {get; }
```

Equal to 1 if the last page spidered was fetched from the cache. Otherwise equal to 0.

### Spider.LastHtml

`Chilkat 11.7.0 · csharp · Spider · LastHtml · property · read-only`

```csharp
public string LastHtml {get; }
```

The HTML text of the last paged fetched by the spider.

### Spider.LastHtmlDescription

`Chilkat 11.7.0 · csharp · Spider · LastHtmlDescription · property · read-only`

```csharp
public string LastHtmlDescription {get; }
```

The HTML META description from the last page fetched by the spider.

### Spider.LastHtmlKeywords

`Chilkat 11.7.0 · csharp · Spider · LastHtmlKeywords · property · read-only`

```csharp
public string LastHtmlKeywords {get; }
```

The HTML META keywords from the last page fetched by the spider.

### Spider.LastHtmlTitle

`Chilkat 11.7.0 · csharp · Spider · LastHtmlTitle · property · read-only`

```csharp
public string LastHtmlTitle {get; }
```

The HTML title from the last page fetched by the spider.

### Spider.LastModDateStr

`Chilkat 11.7.0 · csharp · Spider · LastModDateStr · property · read-only`

```csharp
public string LastModDateStr {get; }
```

The last modification date/time (RFC822 format) from the last page fetched by the spider.

### Spider.LastUrl

`Chilkat 11.7.0 · csharp · Spider · LastUrl · property · read-only`

```csharp
public string LastUrl {get; }
```

The URL of the last page spidered.

### Spider.MaxResponseSize

`Chilkat 11.7.0 · csharp · Spider · MaxResponseSize · property · read/write`

```csharp
public int MaxResponseSize {get; set; }
```

The maximum HTTP response size allowed. The spider will automatically fail any pages larger than this size. The default value is 250,000 bytes.

### Spider.MaxUrlLen

`Chilkat 11.7.0 · csharp · Spider · MaxUrlLen · property · read/write`

```csharp
public int MaxUrlLen {get; set; }
```

The maximum URL length allowed. URLs longer than this are not added to the unspidered list. The default value is 200.

### Spider.NumAvoidPatterns

`Chilkat 11.7.0 · csharp · Spider · NumAvoidPatterns · property · read-only`

```csharp
public int NumAvoidPatterns {get; }
```

The number of avoid patterns previously set by calling AddAvoidPattern.

### Spider.NumFailed

`Chilkat 11.7.0 · csharp · Spider · NumFailed · property · read-only`

```csharp
public int NumFailed {get; }
```

The number of URLs in the object's failed URL list.

### Spider.NumOutboundLinks

`Chilkat 11.7.0 · csharp · Spider · NumOutboundLinks · property · read-only`

```csharp
public int NumOutboundLinks {get; }
```

The number of URLs in the object's outbound links URL list.

### Spider.NumSpidered

`Chilkat 11.7.0 · csharp · Spider · NumSpidered · property · read-only`

```csharp
public int NumSpidered {get; }
```

The number of URLs in the object's already-spidered URL list.

### Spider.NumUnspidered

`Chilkat 11.7.0 · csharp · Spider · NumUnspidered · property · read-only`

```csharp
public int NumUnspidered {get; }
```

The number of URLs in the object's unspidered URL list.

### Spider.PreferIpv6

`Chilkat 11.7.0 · csharp · Spider · PreferIpv6 · property · read/write`

```csharp
public bool PreferIpv6 {get; set; }
```

If `true`, then use IPv6 over IPv4 when both are supported for a particular domain. The default value of this property is `false`, which will choose IPv4 over IPv6.

### Spider.ProxyDomain

`Chilkat 11.7.0 · csharp · Spider · ProxyDomain · property · read/write`

```csharp
public string ProxyDomain {get; set; }
```

The domain name of a proxy host if an HTTP proxy is used.

### Spider.ProxyLogin

`Chilkat 11.7.0 · csharp · Spider · ProxyLogin · property · read/write`

```csharp
public string ProxyLogin {get; set; }
```

If an HTTP proxy is used and it requires authentication, this property specifies the HTTP proxy login.

### Spider.ProxyPassword

`Chilkat 11.7.0 · csharp · Spider · ProxyPassword · property · read/write`

```csharp
public string ProxyPassword {get; set; }
```

If an HTTP proxy is used and it requires authentication, this property specifies the HTTP proxy password.

### Spider.ProxyPort

`Chilkat 11.7.0 · csharp · Spider · ProxyPort · property · read/write`

```csharp
public int ProxyPort {get; set; }
```

The port number of a proxy server if an HTTP proxy is used.

### Spider.ReadTimeout

`Chilkat 11.7.0 · csharp · Spider · ReadTimeout · property · read/write`

```csharp
public int ReadTimeout {get; set; }
```

The maximum number of seconds to wait when reading from an HTTP server.

### Spider.UpdateCache

`Chilkat 11.7.0 · csharp · Spider · UpdateCache · property · read/write`

```csharp
public bool UpdateCache {get; set; }
```

If equal to 1 (true) then pages saved to the cache. If 0, the cache is ignored. The default value is 1. Regardless, if no CacheDir is set then the cache is not used.

### Spider.UserAgent

`Chilkat 11.7.0 · csharp · Spider · UserAgent · property · read/write`

```csharp
public string UserAgent {get; set; }
```

The value of the HTTP user-agent header field to be sent with HTTP requests. This can be set to any desired value, but be aware that some websites may reject requests from unknown user agents.

### Spider.WasRedirected

`Chilkat 11.7.0 · csharp · Spider · WasRedirected · property · read-only · since 9.5.0.85`

```csharp
public bool WasRedirected {get; }
```

Indicates whether the last URL crawled was redirected. (`true` = yes, `false` = no)

### Spider.WindDownCount

`Chilkat 11.7.0 · csharp · Spider · WindDownCount · property · read/write`

```csharp
public int WindDownCount {get; set; }
```

The `wind-down` phase begins when this number of URLs has been spidered. When in the wind-down phase, no new URLs are added to the unspidered list. The default value is 0 which means that there is NO wind-down phase.

## Methods

### Spider.AddAvoidOutboundLinkPattern

`Chilkat 11.7.0 · csharp · Spider · AddAvoidOutboundLinkPattern · method`

```csharp
public void AddAvoidOutboundLinkPattern(string pattern);
```

Adds a wildcarded pattern to prevent collecting matching outbound link URLs. For example, if `*google*` is added, then any outbound links containing the word `google` will be ignored. The `*` character matches zero or more of any character.

### Spider.AddAvoidPattern

`Chilkat 11.7.0 · csharp · Spider · AddAvoidPattern · method`

```csharp
public void AddAvoidPattern(string pattern);
```

Adds a wildcarded pattern to prevent spidering matching URLs. For example, if `*register*` is added, then any url containing the word `register` is not spidered. The `*` character matches zero or more of any character.

### Spider.AddMustMatchPattern

`Chilkat 11.7.0 · csharp · Spider · AddMustMatchPattern · method`

```csharp
public void AddMustMatchPattern(string pattern);
```

Adds a wildcarded pattern to limit spidering to only URLs that match the pattern. For example, if `*/products/*` is added, then only URLs containing `/products/` are spidered. This is helpful for only spidering a portion of a website. The `*` character matches zero or more of any character.

### Spider.AddUnspidered

`Chilkat 11.7.0 · csharp · Spider · AddUnspidered · method`

```csharp
public void AddUnspidered(string url);
```

To begin spidering you must call this method one or more times to provide starting points. It adds a single URL to the object's internal queue of URLs to be spidered.

### Spider.CanonicalizeUrl

`Chilkat 11.7.0 · csharp · Spider · CanonicalizeUrl · method`

```csharp
public string CanonicalizeUrl(string url);
```

Canonicalizes a URL by doing the following:

- Drops username/password if present.
- Drops fragment if present.
- Converts domain to lowercase.
- Removes port 80 or 443
- Remove default.asp, index.html, index.htm, default.html, index.htm, default.htm, index.php, index.asp, default.php, .cfm, .aspx, ,php3, .pl, .cgi, .txt, .shtml, .phtml
- Remove www. from the domain if present.

Returns `null` on failure

### Spider.ClearFailedUrls

`Chilkat 11.7.0 · csharp · Spider · ClearFailedUrls · method`

```csharp
public void ClearFailedUrls();
```

Clears the object's internal list of URLs that could not be downloaded.

### Spider.ClearOutboundLinks

`Chilkat 11.7.0 · csharp · Spider · ClearOutboundLinks · method`

```csharp
public void ClearOutboundLinks();
```

Clears the object's internal list of outbound URLs that will automatically accumulate while spidering.

### Spider.ClearSpideredUrls

`Chilkat 11.7.0 · csharp · Spider · ClearSpideredUrls · method`

```csharp
public void ClearSpideredUrls();
```

Clears the object's internal list of already-spidered URLs that will automatically accumulate while spidering.

### Spider.CrawlNext

`Chilkat 11.7.0 · csharp · Spider · CrawlNext · method`

```csharp
public bool CrawlNext();
```

Crawls the next URL in the internal list of unspidered URLs. The URL is moved from the unspidered list to the spidered list. Any new links within the same domain and not yet spidered are added to the unspidered list. (providing that they do not match `avoid` patterns, etc.) Any new outbound links are added to the outbound URL list. If successful, the HTML of the downloaded page is available in the LastHtml property. If there are no more URLs left unspidered, the method returns `false`. Information about the URL crawled is available in the properties LastUrl, LastFromCache, and LastModDate.

Async variant: `CrawlNextAsync` — same arguments, returns a `Task` (see Async variants below).

### Spider.FetchRobotsText

`Chilkat 11.7.0 · csharp · Spider · FetchRobotsText · method`

```csharp
public string FetchRobotsText();
```

Returns the contents of the robots.txt file from the domain being crawled. This spider object will not crawl URLs excluded by robots.txt. If you believe the spider is not behaving correctly, please notify us at support@chilkatsoft.com and provide information detailing a case that allows us to reproduce the problem.

Returns `null` on failure

Async variant: `FetchRobotsTextAsync` — same arguments, returns a `Task` (see Async variants below).

### Spider.GetAvoidPattern

`Chilkat 11.7.0 · csharp · Spider · GetAvoidPattern · method`

```csharp
public string GetAvoidPattern(int index);
```

Returns the Nth avoid pattern previously added by calling AddAvoidPattern. Indexing begins at 0.

Returns `null` on failure

### Spider.GetBaseDomain

`Chilkat 11.7.0 · csharp · Spider · GetBaseDomain · method`

```csharp
public string GetBaseDomain(string domain);
```

Returns the second-level + top-level domain of the `domain`. For example, if `domain` is `xyz.example.com`, this returns `example.com`. For some domains, such as `xyz.example.co.uk`, the top 3 levels are returned, such as `example.co.uk`.

Returns `null` on failure

### Spider.GetFailedUrl

`Chilkat 11.7.0 · csharp · Spider · GetFailedUrl · method`

```csharp
public string GetFailedUrl(int index);
```

Returns the Nth URL in the failed URL list. Indexing begins at 0.

Returns `null` on failure

### Spider.GetOutboundLink

`Chilkat 11.7.0 · csharp · Spider · GetOutboundLink · method`

```csharp
public string GetOutboundLink(int index);
```

Returns the Nth URL in the outbound link URL list. Indexing begins at 0.

Returns `null` on failure

### Spider.GetSpideredUrl

`Chilkat 11.7.0 · csharp · Spider · GetSpideredUrl · method`

```csharp
public string GetSpideredUrl(int index);
```

Returns the Nth URL in the already-spidered URL list. Indexing begins at 0.

Returns `null` on failure

### Spider.GetUnspideredUrl

`Chilkat 11.7.0 · csharp · Spider · GetUnspideredUrl · method`

```csharp
public string GetUnspideredUrl(int index);
```

Returns the Nth URL in the unspidered URL list. Indexing begins at 0.

Returns `null` on failure

### Spider.GetUrlDomain

`Chilkat 11.7.0 · csharp · Spider · GetUrlDomain · method`

```csharp
public string GetUrlDomain(string url);
```

Returns the domain name part of a URL. For example, if the URL is `https://www.chilkatsoft.com/test.asp`, then `www.chilkatsoft.com` is returned.

Returns `null` on failure

### Spider.Initialize

`Chilkat 11.7.0 · csharp · Spider · Initialize · method`

```csharp
public void Initialize(string domain);
```

Initializes the object to begin spidering a domain. Calling Initialize clears any patterns added via the AddAvoidOutboundLinkPattern, AddAvoidPattern, and AddMustMatchPattern methods. The domain name passed to this method is what is returned by the Domain property. The spider only crawls URLs within the same domain.

### Spider.LoadTaskCaller

`Chilkat 11.7.0 · csharp · Spider · LoadTaskCaller · method · since 9.5.0.80`

```csharp
public bool LoadTaskCaller(Task task);
```

Loads the caller of the task's async method.

Returns true for success, false for failure.

### Spider.RecrawlLast

`Chilkat 11.7.0 · csharp · Spider · RecrawlLast · method`

```csharp
public bool RecrawlLast();
```

Re-crawls the last URL spidered. This helpful when cookies set in a previous page load cause the page to be loaded differently the next time.

Async variant: `RecrawlLastAsync` — same arguments, returns a `Task` (see Async variants below).

### Spider.SkipUnspidered

`Chilkat 11.7.0 · csharp · Spider · SkipUnspidered · method`

```csharp
public void SkipUnspidered(int index);
```

Moves a URL from the unspidered list to the spidered list. This allows an application to skip a specific URL.

### Spider.SleepMs

`Chilkat 11.7.0 · csharp · Spider · SleepMs · method`

```csharp
public void SleepMs(int numMilliseconds);
```

Suspends the execution of the current thread until the time-out interval elapses.

## Events and callbacks

### Spider.AbortCheck (event)

`Chilkat 11.7.0 · csharp · Spider · AbortCheck · event`

```csharp
public event AbortCheckEventHandler OnAbortCheck;
```

Enables a method call to be aborted by triggering the AbortCheck event at intervals defined by the `HeartbeatMs` property. If HeartbeatMs is set to its default value of 0, no events will occur. For instance, set HeartbeatMs to 200 to trigger 5 AbortCheck events per second.

### Chilkat .NET Framework Event Implementation

Args are passed using Chilkat.AbortCheckEventArgs

**Event callback implementation:**

```csharp
private void spider_OnAbortCheck(object sender, Chilkat.AbortCheckEventArgs args)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Spider spider = new Chilkat.Spider();
spider.OnAbortCheck += spider_OnAbortCheck;
```

### Chilkat .NET Core Event Implementation

**Event callback implementation:**

```csharp
public void handleAbortCheck(out bool abort)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Spider spider = new Chilkat.Spider();
// ...
Chilkat.Spider.AbortCheck abortCheck = new Chilkat.Spider.AbortCheck(handleAbortCheck);
spider.setAbortCheckCb(abortCheck);
```

### Spider.PercentDone (event)

`Chilkat 11.7.0 · csharp · Spider · PercentDone · event`

```csharp
public event PercentDoneEventHandler OnPercentDone;
```

This provides the percentage completion for any method involving network communications or time-consuming processing, assuming the progress can be measured as a percentage. This event is triggered only when it's possible and logical to express the operation's progress as a percentage. The `pctDone` argument will range from 1 to 100. For methods that finish quickly, the number of PercentDone callbacks may vary, but the final callback will have `pctDone` equal to 100. For longer operations, callbacks will not exceed one per percentage point (e.g., 1, 2, 3, ..., 98, 99, 100).

The PercentDone callback also acts as an `AbortCheck` event. For fast methods where PercentDone fires, an AbortCheck event may not trigger since the PercentDone callback already provides an opportunity to abort. For longer operations, where time between PercentDone callbacks is extended, AbortCheck callbacks enable more responsive operation termination.

To abort the operation, set the `abort` output argument to `true`. This will cause the method to terminate and return a failure status or corresponding failure value.

### Chilkat .NET Framework Event Implementation

Args are passed using Chilkat.PercentDoneEventArgs

**Event callback implementation:**

```csharp
private void spider_OnPercentDone(object sender, Chilkat.PercentDoneEventArgs args)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Spider spider = new Chilkat.Spider();
spider.OnPercentDone += spider_OnPercentDone;
```

### Chilkat .NET Core Event Implementation

**Event callback implementation:**

```csharp
public void handlePercentDone(int pctDone, out bool abort)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Spider spider = new Chilkat.Spider();
// ...
Chilkat.Spider.PercentDone percentDone = new Chilkat.Spider.PercentDone(handlePercentDone);
spider.setPercentDoneCb(percentDone);
```

### Spider.ProgressInfo (event)

`Chilkat 11.7.0 · csharp · Spider · ProgressInfo · event`

```csharp
public event ProgressInfoEventHandler OnProgressInfo;
```

This event callback provides `tag name`/value pairs that detail what occurs during a method call. To discover existing tag names, create code to handle the event, emit the pairs, and review them. Most tag names are self-explanatory.

Note: Some Chilkat methods don't fire any ProgressInfo events.

### Chilkat .NET Framework Event Implementation

Args are passed using Chilkat.ProgressInfoEventArgs

**Event callback implementation:**

```csharp
private void spider_OnProgressInfo(object sender, Chilkat.ProgressInfoEventArgs args)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Spider spider = new Chilkat.Spider();
spider.OnProgressInfo += spider_OnProgressInfo;
```

### Chilkat .NET Core Event Implementation

**Event callback implementation:**

```csharp
public void handleProgressInfo(string name, string value)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Spider spider = new Chilkat.Spider();
// ...
Chilkat.Spider.ProgressInfo progressInfo = new Chilkat.Spider.ProgressInfo(handleProgressInfo);
spider.setProgressInfoCb(progressInfo);
```

### Spider.TaskCompleted (event)

`Chilkat 11.7.0 · csharp · Spider · TaskCompleted · event`

```csharp
public event TaskCompletedEventHandler OnTaskCompleted;
```

Called from the background thread when an asynchronous task completes.

### Chilkat .NET Framework Event Implementation

Args are passed using Chilkat.TaskCompletedEventArgs

**Event callback implementation:**

```csharp
private void spider_OnTaskCompleted(object sender, Chilkat.TaskCompletedEventArgs args)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Spider spider = new Chilkat.Spider();
spider.OnTaskCompleted += spider_OnTaskCompleted;
```

### Chilkat .NET Core Event Implementation

**Event callback implementation:**

```csharp
public void handleTaskIdCompleted(int taskId)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Spider spider = new Chilkat.Spider();
// ...
Chilkat.Spider.TaskIdCompleted taskIdCompleted = new Chilkat.Spider.TaskIdCompleted(handleTaskIdCompleted);
spider.setTaskIdCompletedCb(taskIdCompleted);
```

## Async variants

Each returns a `Task` instead of the result and takes the same arguments as the synchronous method; run the task, wait for `Finished`, then read the result from the task. No new Async methods are added from 11.7.0 on.

```csharp
public Task CrawlNextAsync();
public Task FetchRobotsTextAsync();
public Task RecrawlLastAsync();
```

## Related classes

[`Task`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/csharp/classes/Task.md)

