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

> Chilkat 11.7.0 · language=c · 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/c/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

**Create/Dispose**

```c
HCkSpider instance = CkSpider_Create();
// ...
CkSpider_Dispose(instance);
```

`HCkSpider CkSpider_Create(void);`

Creates an instance of the HCkSpider object and returns a handle ("void \*" pointer). The handle is passed in the 1st argument for the functions listed on this page.

`void CkSpider_Dispose(HCkSpider handle);`

Objects created by calling CkSpider_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function. Also, any handle returned by a Chilkat "C" function must also be freed by the application by calling the appropriate Dispose method, such as CkSpider_Dispose.

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.

## 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` | `void CkSpider_getDebugLogFilePath(HCkSpider cHandle, HCkString retval); void CkSpider_putDebugLogFilePath(HCkSpider cHandle, const char *newVal); const char *CkSpider_debugLogFilePath(HCkSpider cHandle);` | 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` | `void CkSpider_getLastErrorHtml(HCkSpider cHandle, HCkString retval); const char *CkSpider_lastErrorHtml(HCkSpider cHandle);` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `void CkSpider_getLastErrorText(HCkSpider cHandle, HCkString retval); const char *CkSpider_lastErrorText(HCkSpider cHandle);` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `void CkSpider_getLastErrorXml(HCkSpider cHandle, HCkString retval); const char *CkSpider_lastErrorXml(HCkSpider cHandle);` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `BOOL CkSpider_getLastMethodSuccess(HCkSpider cHandle); void CkSpider_putLastMethodSuccess(HCkSpider cHandle, BOOL newVal);` | read/write | Indicates the success or failure of the most recent method call: `TRUE` means success, `FALSE` means failure. |
| `Utf8` | `BOOL CkSpider_getUtf8(HCkSpider cHandle); void CkSpider_putUtf8(HCkSpider cHandle, BOOL newVal);` | read/write | When set to `TRUE`, all `const char *` arguments and return values are interpreted as UTF-8 strings. |
| `VerboseLogging` | `BOOL CkSpider_getVerboseLogging(HCkSpider cHandle); void CkSpider_putVerboseLogging(HCkSpider cHandle, BOOL newVal);` | read/write | If set to `TRUE`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `void CkSpider_getVersion(HCkSpider cHandle, HCkString retval); const char *CkSpider_version(HCkSpider cHandle);` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `AbortCurrent` | property, read/write | `BOOL CkSpider_getAbortCurrent(HCkSpider cHandle); void CkSpider_putAbortCurrent(HCkSpider cHandle, BOOL newVal);` |
| `AvoidHttps` | property, read/write | `BOOL CkSpider_getAvoidHttps(HCkSpider cHandle); void CkSpider_putAvoidHttps(HCkSpider cHandle, BOOL newVal);` |
| `CacheDir` | property, read/write | `void CkSpider_getCacheDir(HCkSpider cHandle, HCkString retval); void CkSpider_putCacheDir(HCkSpider cHandle, const char *newVal); const char *CkSpider_cacheDir(HCkSpider cHandle);` |
| `ChopAtQuery` | property, read/write | `BOOL CkSpider_getChopAtQuery(HCkSpider cHandle); void CkSpider_putChopAtQuery(HCkSpider cHandle, BOOL newVal);` |
| `ConnectTimeout` | property, read/write | `int CkSpider_getConnectTimeout(HCkSpider cHandle); void CkSpider_putConnectTimeout(HCkSpider cHandle, int newVal);` |
| `Domain` | property, read-only | `void CkSpider_getDomain(HCkSpider cHandle, HCkString retval); const char *CkSpider_domain(HCkSpider cHandle);` |
| `FetchFromCache` | property, read/write | `BOOL CkSpider_getFetchFromCache(HCkSpider cHandle); void CkSpider_putFetchFromCache(HCkSpider cHandle, BOOL newVal);` |
| `FinalRedirectUrl` | property, read-only | `void CkSpider_getFinalRedirectUrl(HCkSpider cHandle, HCkString retval); const char *CkSpider_finalRedirectUrl(HCkSpider cHandle);` |
| `HeartbeatMs` | property, read/write | `int CkSpider_getHeartbeatMs(HCkSpider cHandle); void CkSpider_putHeartbeatMs(HCkSpider cHandle, int newVal);` |
| `LastFromCache` | property, read-only | `BOOL CkSpider_getLastFromCache(HCkSpider cHandle);` |
| `LastHtml` | property, read-only | `void CkSpider_getLastHtml(HCkSpider cHandle, HCkString retval); const char *CkSpider_lastHtml(HCkSpider cHandle);` |
| `LastHtmlDescription` | property, read-only | `void CkSpider_getLastHtmlDescription(HCkSpider cHandle, HCkString retval); const char *CkSpider_lastHtmlDescription(HCkSpider cHandle);` |
| `LastHtmlKeywords` | property, read-only | `void CkSpider_getLastHtmlKeywords(HCkSpider cHandle, HCkString retval); const char *CkSpider_lastHtmlKeywords(HCkSpider cHandle);` |
| `LastHtmlTitle` | property, read-only | `void CkSpider_getLastHtmlTitle(HCkSpider cHandle, HCkString retval); const char *CkSpider_lastHtmlTitle(HCkSpider cHandle);` |
| `LastModDateStr` | property, read-only | `void CkSpider_getLastModDateStr(HCkSpider cHandle, HCkString retval); const char *CkSpider_lastModDateStr(HCkSpider cHandle);` |
| `LastUrl` | property, read-only | `void CkSpider_getLastUrl(HCkSpider cHandle, HCkString retval); const char *CkSpider_lastUrl(HCkSpider cHandle);` |
| `MaxResponseSize` | property, read/write | `int CkSpider_getMaxResponseSize(HCkSpider cHandle); void CkSpider_putMaxResponseSize(HCkSpider cHandle, int newVal);` |
| `MaxUrlLen` | property, read/write | `int CkSpider_getMaxUrlLen(HCkSpider cHandle); void CkSpider_putMaxUrlLen(HCkSpider cHandle, int newVal);` |
| `NumAvoidPatterns` | property, read-only | `int CkSpider_getNumAvoidPatterns(HCkSpider cHandle);` |
| `NumFailed` | property, read-only | `int CkSpider_getNumFailed(HCkSpider cHandle);` |
| `NumOutboundLinks` | property, read-only | `int CkSpider_getNumOutboundLinks(HCkSpider cHandle);` |
| `NumSpidered` | property, read-only | `int CkSpider_getNumSpidered(HCkSpider cHandle);` |
| `NumUnspidered` | property, read-only | `int CkSpider_getNumUnspidered(HCkSpider cHandle);` |
| `PreferIpv6` | property, read/write | `BOOL CkSpider_getPreferIpv6(HCkSpider cHandle); void CkSpider_putPreferIpv6(HCkSpider cHandle, BOOL newVal);` |
| `ProxyDomain` | property, read/write | `void CkSpider_getProxyDomain(HCkSpider cHandle, HCkString retval); void CkSpider_putProxyDomain(HCkSpider cHandle, const char *newVal); const char *CkSpider_proxyDomain(HCkSpider cHandle);` |
| `ProxyLogin` | property, read/write | `void CkSpider_getProxyLogin(HCkSpider cHandle, HCkString retval); void CkSpider_putProxyLogin(HCkSpider cHandle, const char *newVal); const char *CkSpider_proxyLogin(HCkSpider cHandle);` |
| `ProxyPassword` | property, read/write | `void CkSpider_getProxyPassword(HCkSpider cHandle, HCkString retval); void CkSpider_putProxyPassword(HCkSpider cHandle, const char *newVal); const char *CkSpider_proxyPassword(HCkSpider cHandle);` |
| `ProxyPort` | property, read/write | `int CkSpider_getProxyPort(HCkSpider cHandle); void CkSpider_putProxyPort(HCkSpider cHandle, int newVal);` |
| `ReadTimeout` | property, read/write | `int CkSpider_getReadTimeout(HCkSpider cHandle); void CkSpider_putReadTimeout(HCkSpider cHandle, int newVal);` |
| `UpdateCache` | property, read/write | `BOOL CkSpider_getUpdateCache(HCkSpider cHandle); void CkSpider_putUpdateCache(HCkSpider cHandle, BOOL newVal);` |
| `UserAgent` | property, read/write | `void CkSpider_getUserAgent(HCkSpider cHandle, HCkString retval); void CkSpider_putUserAgent(HCkSpider cHandle, const char *newVal); const char *CkSpider_userAgent(HCkSpider cHandle);` |
| `WasRedirected` | property, read-only | `BOOL CkSpider_getWasRedirected(HCkSpider cHandle);` |
| `WindDownCount` | property, read/write | `int CkSpider_getWindDownCount(HCkSpider cHandle); void CkSpider_putWindDownCount(HCkSpider cHandle, int newVal);` |
| `AddAvoidOutboundLinkPattern` | method | `void CkSpider_AddAvoidOutboundLinkPattern(HCkSpider cHandle, const char *pattern);` |
| `AddAvoidPattern` | method | `void CkSpider_AddAvoidPattern(HCkSpider cHandle, const char *pattern);` |
| `AddMustMatchPattern` | method | `void CkSpider_AddMustMatchPattern(HCkSpider cHandle, const char *pattern);` |
| `AddUnspidered` | method | `void CkSpider_AddUnspidered(HCkSpider cHandle, const char *url);` |
| `CanonicalizeUrl` | method | `BOOL CkSpider_CanonicalizeUrl(HCkSpider cHandle, const char *url, HCkString outStr); const char *CkSpider_canonicalizeUrl(HCkSpider cHandle, const char *url);` |
| `ClearFailedUrls` | method | `void CkSpider_ClearFailedUrls(HCkSpider cHandle);` |
| `ClearOutboundLinks` | method | `void CkSpider_ClearOutboundLinks(HCkSpider cHandle);` |
| `ClearSpideredUrls` | method | `void CkSpider_ClearSpideredUrls(HCkSpider cHandle);` |
| `CrawlNext` | method | `BOOL CkSpider_CrawlNext(HCkSpider cHandle);` |
| `FetchRobotsText` | method | `BOOL CkSpider_FetchRobotsText(HCkSpider cHandle, HCkString outStr); const char *CkSpider_fetchRobotsText(HCkSpider cHandle);` |
| `GetAvoidPattern` | method | `BOOL CkSpider_GetAvoidPattern(HCkSpider cHandle, int index, HCkString outStr); const char *CkSpider_getAvoidPattern(HCkSpider cHandle, int index);` |
| `GetBaseDomain` | method | `BOOL CkSpider_GetBaseDomain(HCkSpider cHandle, const char *domain, HCkString outStr); const char *CkSpider_getBaseDomain(HCkSpider cHandle, const char *domain);` |
| `GetFailedUrl` | method | `BOOL CkSpider_GetFailedUrl(HCkSpider cHandle, int index, HCkString outStr); const char *CkSpider_getFailedUrl(HCkSpider cHandle, int index);` |
| `GetOutboundLink` | method | `BOOL CkSpider_GetOutboundLink(HCkSpider cHandle, int index, HCkString outStr); const char *CkSpider_getOutboundLink(HCkSpider cHandle, int index);` |
| `GetSpideredUrl` | method | `BOOL CkSpider_GetSpideredUrl(HCkSpider cHandle, int index, HCkString outStr); const char *CkSpider_getSpideredUrl(HCkSpider cHandle, int index);` |
| `GetUnspideredUrl` | method | `BOOL CkSpider_GetUnspideredUrl(HCkSpider cHandle, int index, HCkString outStr); const char *CkSpider_getUnspideredUrl(HCkSpider cHandle, int index);` |
| `GetUrlDomain` | method | `BOOL CkSpider_GetUrlDomain(HCkSpider cHandle, const char *url, HCkString outStr); const char *CkSpider_getUrlDomain(HCkSpider cHandle, const char *url);` |
| `Initialize` | method | `void CkSpider_Initialize(HCkSpider cHandle, const char *domain);` |
| `LoadTaskCaller` | method | `BOOL CkSpider_LoadTaskCaller(HCkSpider cHandle, HCkTask task);` |
| `RecrawlLast` | method | `BOOL CkSpider_RecrawlLast(HCkSpider cHandle);` |
| `SkipUnspidered` | method | `void CkSpider_SkipUnspidered(HCkSpider cHandle, int index);` |
| `SleepMs` | method | `void CkSpider_SleepMs(HCkSpider cHandle, int numMilliseconds);` |

## Properties

### Spider.AbortCurrent

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

```c
BOOL CkSpider_getAbortCurrent(HCkSpider cHandle);
void CkSpider_putAbortCurrent(HCkSpider cHandle, BOOL newVal);
```

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 · c · Spider · AvoidHttps · property · read/write`

```c
BOOL CkSpider_getAvoidHttps(HCkSpider cHandle);
void CkSpider_putAvoidHttps(HCkSpider cHandle, BOOL newVal);
```

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

### Spider.CacheDir

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

```c
void CkSpider_getCacheDir(HCkSpider cHandle, HCkString retval);
void CkSpider_putCacheDir(HCkSpider cHandle, const char *newVal);
const char *CkSpider_cacheDir(HCkSpider cHandle);
```

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 · c · Spider · ChopAtQuery · property · read/write`

```c
BOOL CkSpider_getChopAtQuery(HCkSpider cHandle);
void CkSpider_putChopAtQuery(HCkSpider cHandle, BOOL newVal);
```

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 · c · Spider · ConnectTimeout · property · read/write`

```c
int CkSpider_getConnectTimeout(HCkSpider cHandle);
void CkSpider_putConnectTimeout(HCkSpider cHandle, int newVal);
```

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

### Spider.Domain

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

```c
void CkSpider_getDomain(HCkSpider cHandle, HCkString retval);
const char *CkSpider_domain(HCkSpider cHandle);
```

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

### Spider.FetchFromCache

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

```c
BOOL CkSpider_getFetchFromCache(HCkSpider cHandle);
void CkSpider_putFetchFromCache(HCkSpider cHandle, BOOL newVal);
```

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 · c · Spider · FinalRedirectUrl · property · read-only · since 9.5.0.85`

```c
void CkSpider_getFinalRedirectUrl(HCkSpider cHandle, HCkString retval);
const char *CkSpider_finalRedirectUrl(HCkSpider cHandle);
```

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 · c · Spider · HeartbeatMs · property · read/write`

```c
int CkSpider_getHeartbeatMs(HCkSpider cHandle);
void CkSpider_putHeartbeatMs(HCkSpider cHandle, int newVal);
```

**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 · c · Spider · LastFromCache · property · read-only`

```c
BOOL CkSpider_getLastFromCache(HCkSpider cHandle);
```

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

### Spider.LastHtml

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

```c
void CkSpider_getLastHtml(HCkSpider cHandle, HCkString retval);
const char *CkSpider_lastHtml(HCkSpider cHandle);
```

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

### Spider.LastHtmlDescription

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

```c
void CkSpider_getLastHtmlDescription(HCkSpider cHandle, HCkString retval);
const char *CkSpider_lastHtmlDescription(HCkSpider cHandle);
```

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

### Spider.LastHtmlKeywords

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

```c
void CkSpider_getLastHtmlKeywords(HCkSpider cHandle, HCkString retval);
const char *CkSpider_lastHtmlKeywords(HCkSpider cHandle);
```

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

### Spider.LastHtmlTitle

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

```c
void CkSpider_getLastHtmlTitle(HCkSpider cHandle, HCkString retval);
const char *CkSpider_lastHtmlTitle(HCkSpider cHandle);
```

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

### Spider.LastModDateStr

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

```c
void CkSpider_getLastModDateStr(HCkSpider cHandle, HCkString retval);
const char *CkSpider_lastModDateStr(HCkSpider cHandle);
```

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

### Spider.LastUrl

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

```c
void CkSpider_getLastUrl(HCkSpider cHandle, HCkString retval);
const char *CkSpider_lastUrl(HCkSpider cHandle);
```

The URL of the last page spidered.

### Spider.MaxResponseSize

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

```c
int CkSpider_getMaxResponseSize(HCkSpider cHandle);
void CkSpider_putMaxResponseSize(HCkSpider cHandle, int newVal);
```

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 · c · Spider · MaxUrlLen · property · read/write`

```c
int CkSpider_getMaxUrlLen(HCkSpider cHandle);
void CkSpider_putMaxUrlLen(HCkSpider cHandle, int newVal);
```

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 · c · Spider · NumAvoidPatterns · property · read-only`

```c
int CkSpider_getNumAvoidPatterns(HCkSpider cHandle);
```

The number of avoid patterns previously set by calling AddAvoidPattern.

### Spider.NumFailed

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

```c
int CkSpider_getNumFailed(HCkSpider cHandle);
```

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

### Spider.NumOutboundLinks

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

```c
int CkSpider_getNumOutboundLinks(HCkSpider cHandle);
```

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

### Spider.NumSpidered

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

```c
int CkSpider_getNumSpidered(HCkSpider cHandle);
```

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

### Spider.NumUnspidered

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

```c
int CkSpider_getNumUnspidered(HCkSpider cHandle);
```

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

### Spider.PreferIpv6

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

```c
BOOL CkSpider_getPreferIpv6(HCkSpider cHandle);
void CkSpider_putPreferIpv6(HCkSpider cHandle, BOOL newVal);
```

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 · c · Spider · ProxyDomain · property · read/write`

```c
void CkSpider_getProxyDomain(HCkSpider cHandle, HCkString retval);
void CkSpider_putProxyDomain(HCkSpider cHandle, const char *newVal);
const char *CkSpider_proxyDomain(HCkSpider cHandle);
```

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

### Spider.ProxyLogin

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

```c
void CkSpider_getProxyLogin(HCkSpider cHandle, HCkString retval);
void CkSpider_putProxyLogin(HCkSpider cHandle, const char *newVal);
const char *CkSpider_proxyLogin(HCkSpider cHandle);
```

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

### Spider.ProxyPassword

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

```c
void CkSpider_getProxyPassword(HCkSpider cHandle, HCkString retval);
void CkSpider_putProxyPassword(HCkSpider cHandle, const char *newVal);
const char *CkSpider_proxyPassword(HCkSpider cHandle);
```

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

### Spider.ProxyPort

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

```c
int CkSpider_getProxyPort(HCkSpider cHandle);
void CkSpider_putProxyPort(HCkSpider cHandle, int newVal);
```

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

### Spider.ReadTimeout

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

```c
int CkSpider_getReadTimeout(HCkSpider cHandle);
void CkSpider_putReadTimeout(HCkSpider cHandle, int newVal);
```

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

### Spider.UpdateCache

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

```c
BOOL CkSpider_getUpdateCache(HCkSpider cHandle);
void CkSpider_putUpdateCache(HCkSpider cHandle, BOOL newVal);
```

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 · c · Spider · UserAgent · property · read/write`

```c
void CkSpider_getUserAgent(HCkSpider cHandle, HCkString retval);
void CkSpider_putUserAgent(HCkSpider cHandle, const char *newVal);
const char *CkSpider_userAgent(HCkSpider cHandle);
```

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 · c · Spider · WasRedirected · property · read-only · since 9.5.0.85`

```c
BOOL CkSpider_getWasRedirected(HCkSpider cHandle);
```

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

### Spider.WindDownCount

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

```c
int CkSpider_getWindDownCount(HCkSpider cHandle);
void CkSpider_putWindDownCount(HCkSpider cHandle, int newVal);
```

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 · c · Spider · AddAvoidOutboundLinkPattern · method`

```c
void CkSpider_AddAvoidOutboundLinkPattern(HCkSpider cHandle, const char *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 · c · Spider · AddAvoidPattern · method`

```c
void CkSpider_AddAvoidPattern(HCkSpider cHandle, const char *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 · c · Spider · AddMustMatchPattern · method`

```c
void CkSpider_AddMustMatchPattern(HCkSpider cHandle, const char *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 · c · Spider · AddUnspidered · method`

```c
void CkSpider_AddUnspidered(HCkSpider cHandle, const char *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 · c · Spider · CanonicalizeUrl · method`

```c
BOOL CkSpider_CanonicalizeUrl(HCkSpider cHandle, const char *url, HCkString outStr);
const char *CkSpider_canonicalizeUrl(HCkSpider cHandle, const char *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 TRUE for success, FALSE for failure.

### Spider.ClearFailedUrls

`Chilkat 11.7.0 · c · Spider · ClearFailedUrls · method`

```c
void CkSpider_ClearFailedUrls(HCkSpider cHandle);
```

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

### Spider.ClearOutboundLinks

`Chilkat 11.7.0 · c · Spider · ClearOutboundLinks · method`

```c
void CkSpider_ClearOutboundLinks(HCkSpider cHandle);
```

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

### Spider.ClearSpideredUrls

`Chilkat 11.7.0 · c · Spider · ClearSpideredUrls · method`

```c
void CkSpider_ClearSpideredUrls(HCkSpider cHandle);
```

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

### Spider.CrawlNext

`Chilkat 11.7.0 · c · Spider · CrawlNext · method`

```c
BOOL CkSpider_CrawlNext(HCkSpider cHandle);
```

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 · c · Spider · FetchRobotsText · method`

```c
BOOL CkSpider_FetchRobotsText(HCkSpider cHandle, HCkString outStr);
const char *CkSpider_fetchRobotsText(HCkSpider cHandle);
```

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 TRUE for success, FALSE for failure.

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

### Spider.GetAvoidPattern

`Chilkat 11.7.0 · c · Spider · GetAvoidPattern · method`

```c
BOOL CkSpider_GetAvoidPattern(HCkSpider cHandle, int index, HCkString outStr);
const char *CkSpider_getAvoidPattern(HCkSpider cHandle, int index);
```

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

Returns TRUE for success, FALSE for failure.

### Spider.GetBaseDomain

`Chilkat 11.7.0 · c · Spider · GetBaseDomain · method`

```c
BOOL CkSpider_GetBaseDomain(HCkSpider cHandle, const char *domain, HCkString outStr);
const char *CkSpider_getBaseDomain(HCkSpider cHandle, const char *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 TRUE for success, FALSE for failure.

### Spider.GetFailedUrl

`Chilkat 11.7.0 · c · Spider · GetFailedUrl · method`

```c
BOOL CkSpider_GetFailedUrl(HCkSpider cHandle, int index, HCkString outStr);
const char *CkSpider_getFailedUrl(HCkSpider cHandle, int index);
```

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

Returns TRUE for success, FALSE for failure.

### Spider.GetOutboundLink

`Chilkat 11.7.0 · c · Spider · GetOutboundLink · method`

```c
BOOL CkSpider_GetOutboundLink(HCkSpider cHandle, int index, HCkString outStr);
const char *CkSpider_getOutboundLink(HCkSpider cHandle, int index);
```

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

Returns TRUE for success, FALSE for failure.

### Spider.GetSpideredUrl

`Chilkat 11.7.0 · c · Spider · GetSpideredUrl · method`

```c
BOOL CkSpider_GetSpideredUrl(HCkSpider cHandle, int index, HCkString outStr);
const char *CkSpider_getSpideredUrl(HCkSpider cHandle, int index);
```

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

Returns TRUE for success, FALSE for failure.

### Spider.GetUnspideredUrl

`Chilkat 11.7.0 · c · Spider · GetUnspideredUrl · method`

```c
BOOL CkSpider_GetUnspideredUrl(HCkSpider cHandle, int index, HCkString outStr);
const char *CkSpider_getUnspideredUrl(HCkSpider cHandle, int index);
```

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

Returns TRUE for success, FALSE for failure.

### Spider.GetUrlDomain

`Chilkat 11.7.0 · c · Spider · GetUrlDomain · method`

```c
BOOL CkSpider_GetUrlDomain(HCkSpider cHandle, const char *url, HCkString outStr);
const char *CkSpider_getUrlDomain(HCkSpider cHandle, const char *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 TRUE for success, FALSE for failure.

### Spider.Initialize

`Chilkat 11.7.0 · c · Spider · Initialize · method`

```c
void CkSpider_Initialize(HCkSpider cHandle, const char *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 · c · Spider · LoadTaskCaller · method · since 9.5.0.80`

```c
BOOL CkSpider_LoadTaskCaller(HCkSpider cHandle, HCkTask task);
```

Loads the caller of the task's async method.

Returns TRUE for success, FALSE for failure.

### Spider.RecrawlLast

`Chilkat 11.7.0 · c · Spider · RecrawlLast · method`

```c
BOOL CkSpider_RecrawlLast(HCkSpider cHandle);
```

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 · c · Spider · SkipUnspidered · method`

```c
void CkSpider_SkipUnspidered(HCkSpider cHandle, 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 · c · Spider · SleepMs · method`

```c
void CkSpider_SleepMs(HCkSpider cHandle, int numMilliseconds);
```

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

## Events and callbacks

This binding delivers progress information through callbacks (AbortCheck, PercentDone, ProgressInfo, TaskCompleted) rather than events. See `guide.md` for how to attach them in C.

## 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.

```c
HCkTask CkSpider_CrawlNextAsync(HCkSpider cHandle);
HCkTask CkSpider_FetchRobotsTextAsync(HCkSpider cHandle);
HCkTask CkSpider_RecrawlLastAsync(HCkSpider cHandle);
```

## Related classes

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

