CkSpider C++ Class Reference (Visual C++)

CkSpider

* This is a freeware class/component/library.

Chilkat Spider web crawler component.

Properties

bool get_AvoidHttps(void);
void put_AvoidHttps(bool newVal);

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

void get_CacheDir(CkString &strOut);
void put_CacheDir(const char *dir);

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.

bool get_ChopAtQuery(void);
void put_ChopAtQuery(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).

int get_ConnectTimeout(void);
void put_ConnectTimeout(long numSeconds);

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

void get_Domain(CkString &strOut);

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

bool get_FetchFromCache(void);
void put_FetchFromCache(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.

long get_HeartbeatMs(void);
void put_HeartbeatMs(long newVal);

To be documented soon...

void LastErrorHtml(CkString &str);

Error information in HTML format for the last method called.

void LastErrorText(CkString &str);

Error information in plain-text format for the last method called.

void LastErrorXml(CkString &str);

Error information in XML format for the last method called.

bool get_LastFromCache(void);

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

void get_LastHtml(CkString &strOut);

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

void get_LastHtmlDescription(CkString &strOut);

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

void get_LastHtmlKeywords(CkString &strOut);

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

void get_LastHtmlTitle(CkString &strOut);

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

void get_LastModDate(SYSTEMTIME &sysTime);

The last-modification date of the last URL spidered.

void get_LastModDateStr(CkString &strOut);

The last modification date/time from the last page fetched by the spider.

void get_LastUrl(CkString &strOut);

The URL of the last page spidered.

int get_MaxResponseSize(void);
void put_MaxResponseSize(long 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.

int get_MaxUrlLen(void);
void put_MaxUrlLen(long newVal);

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

int get_NumAvoidPatterns(void);

The number of avoid patterns previously set by calling AddAvoidPattern.

int get_NumFailed(void);

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

int get_NumOutboundLinks(void);

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

int get_NumSpidered(void);

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

int get_NumUnspidered(void);

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

void get_ProxyDomain(CkString &str);
void put_ProxyDomain(const char *newVal);

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

void get_ProxyLogin(CkString &str);
void put_ProxyLogin(const char *newVal);

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

void get_ProxyPassword(CkString &str);
void put_ProxyPassword(const char *newVal);

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

int get_ProxyPort(void);
void put_ProxyPort(int newVal);

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

int get_ReadTimeout(void);
void put_ReadTimeout(long numSeconds);

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

bool get_UpdateCache(void);
void put_UpdateCache(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.

void get_UserAgent(CkString &strOut);
void put_UserAgent(const char *ua);

To be documented soon...

bool get_Utf8(void) const;
void put_Utf8(bool b);

To be documented soon...

int get_WindDownCount(void);
void put_WindDownCount(long 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

void AddAvoidOutboundLinkPattern(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.

void AddAvoidPattern(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.

void AddMustMatchPattern(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.

void AddUnspidered(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 component's internal queue of URLs to be spidered.

void CanonicalizeUrl(const char * url, CkString & urlOut);

To be documented soon...

void ClearFailedUrls();

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

void ClearOutboundLinks();

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

void ClearSpideredUrls();

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

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. This method returns the HTML of the page downloaded. If there are no more URLs left unspidered, a NULL value is returned. Information about the URL crawled is available in the properties LastUrl, LastFromCache, and LastModDate.

bool FetchRobotsText(CkString & strOut);

Returns the contents of the robots.txt file from the domain being crawled. This spider component 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.

bool GetAvoidPattern(long index, CkString & strOut);

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

Returns true for success, false for failure.

void GetBaseDomain(const char * domain, CkString & domainOut);

To be documented soon...

void GetDomain(const char * url, CkString & domainOut);

To be documented soon...

bool GetFailedUrl(long index, CkString & strOut);

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

Returns true for success, false for failure.

bool GetOutboundLink(long index, CkString & strOut);

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

Returns true for success, false for failure.

bool GetSpideredUrl(long index, CkString & strOut);

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

Returns true for success, false for failure.

bool GetUnspideredUrl(long index, CkString & strOut);

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

Returns true for success, false for failure.

void Initialize(const char * domain);

Initializes the component 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.

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.

bool SaveLastError(const char * filename);

Saves the last error information to an XML formatted file.

void SkipUnspidered(long index);

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

void SleepMs(long millisec);

To be documented soon...

const char * avoidPattern(long index);

To be documented soon...

const char * cacheDir();

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.

const char * canonicalizeUrl(const char * url);

To be documented soon...

const char * domain();

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

const char * failedUrl(long index);

To be documented soon...

const char * fetchRobotsText();

Returns the contents of the robots.txt file from the domain being crawled. This spider component 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.

const char * getAvoidPattern(long index);

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

const char * getBaseDomain(const char * domain);

To be documented soon...

const char * getDomain(const char * url);

To be documented soon...

const char * getFailedUrl(long index);

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

const char * getOutboundLink(long index);

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

const char * getSpideredUrl(long index);

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

const char * getUnspideredUrl(long index);

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

const char * lastErrorHtml();

Error information in HTML format for the last method called.

const char * lastErrorText();

Error information in plain-text format for the last method called.

const char * lastErrorXml();

Error information in XML format for the last method called.

const char * lastHtml();

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

const char * lastHtmlDescription();

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

const char * lastHtmlKeywords();

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

const char * lastHtmlTitle();

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

const char * lastModDateStr();

The last modification date/time from the last page fetched by the spider.

const char * lastUrl();

The URL of the last page spidered.

const char * outboundLink(long index);

To be documented soon...

const char * proxyDomain();

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

const char * proxyLogin();

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

const char * proxyPassword();

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

const char * spideredUrl(long index);

To be documented soon...

const char * unspideredUrl(long index);

To be documented soon...

const char * userAgent();

To be documented soon...