---
product: Chilkat
product_version: 11.7.0
language: ckpython
language_label: CkPython
class: Spider
class_name: CkSpider
license: free
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/pythonCkSpiderRef.html
---
# Chilkat Spider — CkPython — v11.7.0

> Chilkat 11.7.0 · language=ckpython · class=Spider (CkSpider)
> 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/ckpython/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**

```python
obj = chilkat.CkSpider()
```

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

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` | `# strVal is a string # ckStr is a CkString spider.get_DebugLogFilePath(ckStr); strVal = spider.debugLogFilePath(); spider.put_DebugLogFilePath(strVal);` | 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` | `# strVal is a string # ckStr is a CkString spider.get_LastErrorHtml(ckStr); strVal = spider.lastErrorHtml();` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `# strVal is a string # ckStr is a CkString spider.get_LastErrorText(ckStr); strVal = spider.lastErrorText();` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `# strVal is a string # ckStr is a CkString spider.get_LastErrorXml(ckStr); strVal = spider.lastErrorXml();` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `# boolVal is a boolean boolVal = spider.get_LastMethodSuccess(); spider.put_LastMethodSuccess(boolVal);` | read/write | Indicates the success or failure of the most recent method call: `True` means success, `False` means failure. |
| `Utf8` | `# boolVal is a boolean boolVal = spider.get_Utf8(); spider.put_Utf8(boolVal);` | read/write | When set to `True`, all `string` arguments and return values are interpreted as UTF-8 strings. |
| `VerboseLogging` | `# boolVal is a boolean boolVal = spider.get_VerboseLogging(); spider.put_VerboseLogging(boolVal);` | read/write | If set to `True`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `# strVal is a string # ckStr is a CkString spider.get_Version(ckStr); strVal = spider.version();` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `AbortCurrent` | property, read/write | `# boolVal is a boolean boolVal = spider.get_AbortCurrent(); spider.put_AbortCurrent(boolVal);` |
| `AvoidHttps` | property, read/write | `# boolVal is a boolean boolVal = spider.get_AvoidHttps(); spider.put_AvoidHttps(boolVal);` |
| `CacheDir` | property, read/write | `# strVal is a string # ckStr is a CkString spider.get_CacheDir(ckStr); strVal = spider.cacheDir(); spider.put_CacheDir(strVal);` |
| `ChopAtQuery` | property, read/write | `# boolVal is a boolean boolVal = spider.get_ChopAtQuery(); spider.put_ChopAtQuery(boolVal);` |
| `ConnectTimeout` | property, read/write | `# intVal is an integer intVal = spider.get_ConnectTimeout(); spider.put_ConnectTimeout(intVal);` |
| `Domain` | property, read-only | `# strVal is a string # ckStr is a CkString spider.get_Domain(ckStr); strVal = spider.domain();` |
| `FetchFromCache` | property, read/write | `# boolVal is a boolean boolVal = spider.get_FetchFromCache(); spider.put_FetchFromCache(boolVal);` |
| `FinalRedirectUrl` | property, read-only | `# strVal is a string # ckStr is a CkString spider.get_FinalRedirectUrl(ckStr); strVal = spider.finalRedirectUrl();` |
| `LastFromCache` | property, read-only | `# boolVal is a boolean boolVal = spider.get_LastFromCache();` |
| `LastHtml` | property, read-only | `# strVal is a string # ckStr is a CkString spider.get_LastHtml(ckStr); strVal = spider.lastHtml();` |
| `LastHtmlDescription` | property, read-only | `# strVal is a string # ckStr is a CkString spider.get_LastHtmlDescription(ckStr); strVal = spider.lastHtmlDescription();` |
| `LastHtmlKeywords` | property, read-only | `# strVal is a string # ckStr is a CkString spider.get_LastHtmlKeywords(ckStr); strVal = spider.lastHtmlKeywords();` |
| `LastHtmlTitle` | property, read-only | `# strVal is a string # ckStr is a CkString spider.get_LastHtmlTitle(ckStr); strVal = spider.lastHtmlTitle();` |
| `LastModDateStr` | property, read-only | `# strVal is a string # ckStr is a CkString spider.get_LastModDateStr(ckStr); strVal = spider.lastModDateStr();` |
| `LastUrl` | property, read-only | `# strVal is a string # ckStr is a CkString spider.get_LastUrl(ckStr); strVal = spider.lastUrl();` |
| `MaxResponseSize` | property, read/write | `# intVal is an integer intVal = spider.get_MaxResponseSize(); spider.put_MaxResponseSize(intVal);` |
| `MaxUrlLen` | property, read/write | `# intVal is an integer intVal = spider.get_MaxUrlLen(); spider.put_MaxUrlLen(intVal);` |
| `NumAvoidPatterns` | property, read-only | `# intVal is an integer intVal = spider.get_NumAvoidPatterns();` |
| `NumFailed` | property, read-only | `# intVal is an integer intVal = spider.get_NumFailed();` |
| `NumOutboundLinks` | property, read-only | `# intVal is an integer intVal = spider.get_NumOutboundLinks();` |
| `NumSpidered` | property, read-only | `# intVal is an integer intVal = spider.get_NumSpidered();` |
| `NumUnspidered` | property, read-only | `# intVal is an integer intVal = spider.get_NumUnspidered();` |
| `PreferIpv6` | property, read/write | `# boolVal is a boolean boolVal = spider.get_PreferIpv6(); spider.put_PreferIpv6(boolVal);` |
| `ProxyDomain` | property, read/write | `# strVal is a string # ckStr is a CkString spider.get_ProxyDomain(ckStr); strVal = spider.proxyDomain(); spider.put_ProxyDomain(strVal);` |
| `ProxyLogin` | property, read/write | `# strVal is a string # ckStr is a CkString spider.get_ProxyLogin(ckStr); strVal = spider.proxyLogin(); spider.put_ProxyLogin(strVal);` |
| `ProxyPassword` | property, read/write | `# strVal is a string # ckStr is a CkString spider.get_ProxyPassword(ckStr); strVal = spider.proxyPassword(); spider.put_ProxyPassword(strVal);` |
| `ProxyPort` | property, read/write | `# intVal is an integer intVal = spider.get_ProxyPort(); spider.put_ProxyPort(intVal);` |
| `ReadTimeout` | property, read/write | `# intVal is an integer intVal = spider.get_ReadTimeout(); spider.put_ReadTimeout(intVal);` |
| `UpdateCache` | property, read/write | `# boolVal is a boolean boolVal = spider.get_UpdateCache(); spider.put_UpdateCache(boolVal);` |
| `UserAgent` | property, read/write | `# strVal is a string # ckStr is a CkString spider.get_UserAgent(ckStr); strVal = spider.userAgent(); spider.put_UserAgent(strVal);` |
| `WasRedirected` | property, read-only | `# boolVal is a boolean boolVal = spider.get_WasRedirected();` |
| `WindDownCount` | property, read/write | `# intVal is an integer intVal = spider.get_WindDownCount(); spider.put_WindDownCount(intVal);` |
| `AddAvoidOutboundLinkPattern` | method | `# pattern is a string spider.AddAvoidOutboundLinkPattern(pattern);` |
| `AddAvoidPattern` | method | `# pattern is a string spider.AddAvoidPattern(pattern);` |
| `AddMustMatchPattern` | method | `# pattern is a string spider.AddMustMatchPattern(pattern);` |
| `AddUnspidered` | method | `# url is a string spider.AddUnspidered(url);` |
| `CanonicalizeUrl` | method | `# url is a string # outStr is a CkString (output) status = spider.CanonicalizeUrl(url, outStr); retStr = spider.canonicalizeUrl(url);` |
| `ClearFailedUrls` | method | `spider.ClearFailedUrls();` |
| `ClearOutboundLinks` | method | `spider.ClearOutboundLinks();` |
| `ClearSpideredUrls` | method | `spider.ClearSpideredUrls();` |
| `CrawlNext` | method | `retBool = spider.CrawlNext();` |
| `FetchRobotsText` | method | `# outStr is a CkString (output) status = spider.FetchRobotsText(outStr); retStr = spider.fetchRobotsText();` |
| `GetAvoidPattern` | method | `# index is an integer # outStr is a CkString (output) status = spider.GetAvoidPattern(index, outStr); retStr = spider.getAvoidPattern(index);` |
| `GetBaseDomain` | method | `# domain is a string # outStr is a CkString (output) status = spider.GetBaseDomain(domain, outStr); retStr = spider.getBaseDomain(domain);` |
| `GetFailedUrl` | method | `# index is an integer # outStr is a CkString (output) status = spider.GetFailedUrl(index, outStr); retStr = spider.getFailedUrl(index);` |
| `GetOutboundLink` | method | `# index is an integer # outStr is a CkString (output) status = spider.GetOutboundLink(index, outStr); retStr = spider.getOutboundLink(index);` |
| `GetSpideredUrl` | method | `# index is an integer # outStr is a CkString (output) status = spider.GetSpideredUrl(index, outStr); retStr = spider.getSpideredUrl(index);` |
| `GetUnspideredUrl` | method | `# index is an integer # outStr is a CkString (output) status = spider.GetUnspideredUrl(index, outStr); retStr = spider.getUnspideredUrl(index);` |
| `GetUrlDomain` | method | `# url is a string # outStr is a CkString (output) status = spider.GetUrlDomain(url, outStr); retStr = spider.getUrlDomain(url);` |
| `Initialize` | method | `# domain is a string spider.Initialize(domain);` |
| `LoadTaskCaller` | method | `# task is a CkTask status = spider.LoadTaskCaller(task);` |
| `RecrawlLast` | method | `retBool = spider.RecrawlLast();` |
| `SkipUnspidered` | method | `# index is an integer spider.SkipUnspidered(index);` |
| `SleepMs` | method | `# numMilliseconds is an integer spider.SleepMs(numMilliseconds);` |

## Properties

### Spider.AbortCurrent

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

```python
# boolVal is a boolean

boolVal = spider.get_AbortCurrent();

spider.put_AbortCurrent(boolVal);
```

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

```python
# boolVal is a boolean

boolVal = spider.get_AvoidHttps();

spider.put_AvoidHttps(boolVal);
```

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

### Spider.CacheDir

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

```python
# strVal is a string

# ckStr is a CkString

spider.get_CacheDir(ckStr);

strVal = spider.cacheDir();

spider.put_CacheDir(strVal);
```

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

```python
# boolVal is a boolean

boolVal = spider.get_ChopAtQuery();

spider.put_ChopAtQuery(boolVal);
```

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

```python
# intVal is an integer

intVal = spider.get_ConnectTimeout();

spider.put_ConnectTimeout(intVal);
```

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

### Spider.Domain

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

```python
# strVal is a string

# ckStr is a CkString

spider.get_Domain(ckStr);

strVal = spider.domain();
```

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

### Spider.FetchFromCache

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

```python
# boolVal is a boolean

boolVal = spider.get_FetchFromCache();

spider.put_FetchFromCache(boolVal);
```

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

```python
# strVal is a string

# ckStr is a CkString

spider.get_FinalRedirectUrl(ckStr);

strVal = spider.finalRedirectUrl();
```

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

### Spider.LastFromCache

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

```python
# boolVal is a boolean

boolVal = spider.get_LastFromCache();
```

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

### Spider.LastHtml

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

```python
# strVal is a string

# ckStr is a CkString

spider.get_LastHtml(ckStr);

strVal = spider.lastHtml();
```

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

### Spider.LastHtmlDescription

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

```python
# strVal is a string

# ckStr is a CkString

spider.get_LastHtmlDescription(ckStr);

strVal = spider.lastHtmlDescription();
```

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

### Spider.LastHtmlKeywords

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

```python
# strVal is a string

# ckStr is a CkString

spider.get_LastHtmlKeywords(ckStr);

strVal = spider.lastHtmlKeywords();
```

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

### Spider.LastHtmlTitle

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

```python
# strVal is a string

# ckStr is a CkString

spider.get_LastHtmlTitle(ckStr);

strVal = spider.lastHtmlTitle();
```

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

### Spider.LastModDateStr

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

```python
# strVal is a string

# ckStr is a CkString

spider.get_LastModDateStr(ckStr);

strVal = spider.lastModDateStr();
```

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

### Spider.LastUrl

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

```python
# strVal is a string

# ckStr is a CkString

spider.get_LastUrl(ckStr);

strVal = spider.lastUrl();
```

The URL of the last page spidered.

### Spider.MaxResponseSize

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

```python
# intVal is an integer

intVal = spider.get_MaxResponseSize();

spider.put_MaxResponseSize(intVal);
```

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

```python
# intVal is an integer

intVal = spider.get_MaxUrlLen();

spider.put_MaxUrlLen(intVal);
```

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

```python
# intVal is an integer

intVal = spider.get_NumAvoidPatterns();
```

The number of avoid patterns previously set by calling AddAvoidPattern.

### Spider.NumFailed

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

```python
# intVal is an integer

intVal = spider.get_NumFailed();
```

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

### Spider.NumOutboundLinks

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

```python
# intVal is an integer

intVal = spider.get_NumOutboundLinks();
```

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

### Spider.NumSpidered

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

```python
# intVal is an integer

intVal = spider.get_NumSpidered();
```

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

### Spider.NumUnspidered

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

```python
# intVal is an integer

intVal = spider.get_NumUnspidered();
```

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

### Spider.PreferIpv6

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

```python
# boolVal is a boolean

boolVal = spider.get_PreferIpv6();

spider.put_PreferIpv6(boolVal);
```

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

```python
# strVal is a string

# ckStr is a CkString

spider.get_ProxyDomain(ckStr);

strVal = spider.proxyDomain();

spider.put_ProxyDomain(strVal);
```

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

### Spider.ProxyLogin

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

```python
# strVal is a string

# ckStr is a CkString

spider.get_ProxyLogin(ckStr);

strVal = spider.proxyLogin();

spider.put_ProxyLogin(strVal);
```

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

### Spider.ProxyPassword

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

```python
# strVal is a string

# ckStr is a CkString

spider.get_ProxyPassword(ckStr);

strVal = spider.proxyPassword();

spider.put_ProxyPassword(strVal);
```

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

### Spider.ProxyPort

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

```python
# intVal is an integer

intVal = spider.get_ProxyPort();

spider.put_ProxyPort(intVal);
```

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

### Spider.ReadTimeout

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

```python
# intVal is an integer

intVal = spider.get_ReadTimeout();

spider.put_ReadTimeout(intVal);
```

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

### Spider.UpdateCache

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

```python
# boolVal is a boolean

boolVal = spider.get_UpdateCache();

spider.put_UpdateCache(boolVal);
```

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

```python
# strVal is a string

# ckStr is a CkString

spider.get_UserAgent(ckStr);

strVal = spider.userAgent();

spider.put_UserAgent(strVal);
```

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

```python
# boolVal is a boolean

boolVal = spider.get_WasRedirected();
```

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

### Spider.WindDownCount

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

```python
# intVal is an integer

intVal = spider.get_WindDownCount();

spider.put_WindDownCount(intVal);
```

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

```python
# pattern is a string

spider.AddAvoidOutboundLinkPattern(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 · ckpython · Spider · AddAvoidPattern · method`

```python
# pattern is a string

spider.AddAvoidPattern(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 · ckpython · Spider · AddMustMatchPattern · method`

```python
# pattern is a string

spider.AddMustMatchPattern(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 · ckpython · Spider · AddUnspidered · method`

```python
# url is a string

spider.AddUnspidered(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 · ckpython · Spider · CanonicalizeUrl · method`

```python
# url is a string

# outStr is a CkString (output)

status = spider.CanonicalizeUrl(url, outStr);

retStr = spider.canonicalizeUrl(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 · ckpython · Spider · ClearFailedUrls · method`

```python
spider.ClearFailedUrls();
```

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

### Spider.ClearOutboundLinks

`Chilkat 11.7.0 · ckpython · Spider · ClearOutboundLinks · method`

```python
spider.ClearOutboundLinks();
```

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

### Spider.ClearSpideredUrls

`Chilkat 11.7.0 · ckpython · Spider · ClearSpideredUrls · method`

```python
spider.ClearSpideredUrls();
```

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

### Spider.CrawlNext

`Chilkat 11.7.0 · ckpython · Spider · CrawlNext · method`

```python
retBool = spider.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 · ckpython · Spider · FetchRobotsText · method`

```python
# outStr is a CkString (output)

status = spider.FetchRobotsText(outStr);

retStr = spider.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 True for success, False for failure.

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

### Spider.GetAvoidPattern

`Chilkat 11.7.0 · ckpython · Spider · GetAvoidPattern · method`

```python
# index is an integer

# outStr is a CkString (output)

status = spider.GetAvoidPattern(index, outStr);

retStr = spider.getAvoidPattern(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 · ckpython · Spider · GetBaseDomain · method`

```python
# domain is a string

# outStr is a CkString (output)

status = spider.GetBaseDomain(domain, outStr);

retStr = spider.getBaseDomain(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 · ckpython · Spider · GetFailedUrl · method`

```python
# index is an integer

# outStr is a CkString (output)

status = spider.GetFailedUrl(index, outStr);

retStr = spider.getFailedUrl(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 · ckpython · Spider · GetOutboundLink · method`

```python
# index is an integer

# outStr is a CkString (output)

status = spider.GetOutboundLink(index, outStr);

retStr = spider.getOutboundLink(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 · ckpython · Spider · GetSpideredUrl · method`

```python
# index is an integer

# outStr is a CkString (output)

status = spider.GetSpideredUrl(index, outStr);

retStr = spider.getSpideredUrl(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 · ckpython · Spider · GetUnspideredUrl · method`

```python
# index is an integer

# outStr is a CkString (output)

status = spider.GetUnspideredUrl(index, outStr);

retStr = spider.getUnspideredUrl(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 · ckpython · Spider · GetUrlDomain · method`

```python
# url is a string

# outStr is a CkString (output)

status = spider.GetUrlDomain(url, outStr);

retStr = spider.getUrlDomain(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 · ckpython · Spider · Initialize · method`

```python
# domain is a string

spider.Initialize(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 · ckpython · Spider · LoadTaskCaller · method · since 9.5.0.80`

```python
# task is a CkTask

status = spider.LoadTaskCaller(task);
```

Loads the caller of the task's async method.

Returns True for success, False for failure.

### Spider.RecrawlLast

`Chilkat 11.7.0 · ckpython · Spider · RecrawlLast · method`

```python
retBool = spider.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 · ckpython · Spider · SkipUnspidered · method`

```python
# index is an integer

spider.SkipUnspidered(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 · ckpython · Spider · SleepMs · method`

```python
# numMilliseconds is an integer

spider.SleepMs(numMilliseconds);
```

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

## Events and callbacks

This binding has no event callbacks. For progress, percent-done or cancellation use the `*Async` variant of a method and poll the returned `Task` (`PercentDone`, `Finished`, `Cancel`).

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

```python
# returns a CkTask

ret_task = spider.CrawlNextAsync();
# returns a CkTask

ret_task = spider.FetchRobotsTextAsync();
# returns a CkTask

ret_task = spider.RecrawlLastAsync();
```

## Related classes

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

