Chilkat C# Spider Class Reference
Spider
* This is a freeware class/component/library.
Chilkat Spider web crawler component.
Object Creation
(C#)
Chilkat.Spider obj = new Chilkat.Spider();
(VB.NET)
Dim obj As New Chilkat.Spider()
Properties
public bool AvoidHttps {get; set; }
If set the 1 (true) the spider will avoid all HTTPS URLs. The default is 0 (false).
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.
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).
public int ConnectTimeout {get; set; }
The maximum number of seconds to wait while connecting to an HTTP server.
public string Domain {get; }
The domain name that is being spidered. This is the domain previously set in the Initialize method.
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.
public int HeartbeatMs {get; set; }
To be documented soon...
public string LastErrorHtml {get; }
Error information in HTML format for the last method called.
public string LastErrorText {get; }
Error information in plain-text format for the last method called.
public string LastErrorXml {get; }
Error information in XML format for the last method called.
public bool LastFromCache {get; }
Equal to 1 if the last page spidered was fetched from the cache. Otherwise equal to 0.
public string LastHtml {get; }
The HTML text of the last paged fetched by the spider.
public string LastHtmlDescription {get; }
The HTML META description from the last page fetched by the spider.
public string LastHtmlKeywords {get; }
The HTML META keywords from the last page fetched by the spider.
public string LastHtmlTitle {get; }
The HTML title from the last page fetched by the spider.
public string LastModDateStr {get; }
The last modification date/time from the last page fetched by the spider.
public string LastUrl {get; }
The URL of the last page spidered.
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.
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.
public int NumAvoidPatterns {get; }
The number of avoid patterns previously set by calling AddAvoidPattern.
public int NumFailed {get; }
The number of URLs in the component's failed URL list.
public int NumOutboundLinks {get; }
The number of URLs in the component's outbound links URL list.
public int NumSpidered {get; }
The number of URLs in the component's already-spidered URL list.
public int NumUnspidered {get; }
The number of URLs in the component's unspidered URL list.
public string ProxyDomain {get; set; }
(PreRelease) The domain name of a proxy host if an HTTP proxy is used.
public string ProxyLogin {get; set; }
(PreRelease) If an HTTP proxy is used and it requires authentication, this property specifies the HTTP proxy login.
public string ProxyPassword {get; set; }
(PreRelease) If an HTTP proxy is used and it requires authentication, this property specifies the HTTP proxy password.
public int ProxyPort {get; set; }
(PreRelease) The port number of a proxy server if an HTTP proxy is used.
public int ReadTimeout {get; set; }
The maximum number of seconds to wait when reading from an HTTP server.
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.
public string UserAgent {get; set; }
To be documented soon...
public bool VerboseLogging {get; set; }
To be documented soon...
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
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.
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.
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.
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 component's internal queue of URLs to be spidered.
public string CanonicalizeUrl(string url);
To be documented soon...
public void ClearFailedUrls();
Clears the component's internal list of URLs that could not be downloaded.
public void ClearOutboundLinks();
Clears the component's internal list of outbound URLs that will automatically accumulate while spidering.
public void ClearSpideredUrls();
Clears the component's internal list of already-spidered URLs that will automatically accumulate while spidering.
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.
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.
public string 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. Returns a null on failure
public string GetAvoidPattern(int index);
Returns the Nth avoid pattern previously added by calling AddAvoidPattern. Indexing begins at 0. Returns a null on failure
public string GetBaseDomain(string domain);
To be documented soon...
public string GetDomain(string url);
Returns the domain name part of a URL. For example, if the URL is "http://www.chilkatsoft.com/test.asp", then "www.chilkatsoft.com" is returned. Returns a null on failure
public string GetFailedUrl(int index);
Returns the Nth URL in the failed URL list. Indexing begins at 0. Returns a null on failure
public string GetOutboundLink(int index);
Returns the Nth URL in the outbound link URL list. Indexing begins at 0. Returns a null on failure
public string GetSpideredUrl(int index);
Returns the Nth URL in the already-spidered URL list. Indexing begins at 0. Returns a null on failure
public string GetUnspideredUrl(int index);
Returns the Nth URL in the unspidered URL list. Indexing begins at 0. Returns a null on failure
public void Initialize(string 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.
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.
public bool SaveLastError(string filename);
Saves the last error information to an XML formatted file.
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.
public void SleepMs(int millisec);
To be documented soon...
|