The Chilkat Spider component has disk caching capabilities. To setup a disk cache, create a new directory anywhere on your local hard drive and set the CacheDir property to the path. For example, you might create "c:/spiderCache/". The UpdateCache property controls whether downloaded pages are saved to the cache. The FetchFromCache property controls whether the cache is first checked for pages. The LastFromCache property tells whether the last URL fetched came from cache or not.

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,
SPIDERXLib_TLB,
OleCtrls; ... procedure TForm1.Button1Click(Sender: TObject);
var
spider: TSpider;
i: Integer;
success: Integer; begin
// The Chilkat Spider component/library is free.
spider := TSpider.Create(Self); // Set our cache directory and make sure saving-to-cache and fetching-from-cache
// are both turned on:
spider.CacheDir := 'c:/spiderCache/';
spider.FetchFromCache := ;
spider.UpdateCache := ; // If you run this code twice, you'll find that the 2nd run is extremely fast
// because the pages will be retrieved from cache. // The spider object crawls a single web site at a time. As you'll see
// in later examples, you can collect outbound links and use them to
// crawl the web. For now, we'll simply spider 10 pages of chilkatsoft.com
spider.Initialize('www.chilkatsoft.com'); // Add the 1st URL:
spider.AddUnspidered('http://www.chilkatsoft.com/'); // Begin crawling the site by calling CrawlNext repeatedly. for i := to do
begin success := spider.CrawlNext();
if (success = ) then
begin
// Show the URL of the page just spidered.
Memo1.Lines.Add(spider.LastUrl);
// The HTML is available in the LastHtml property
end
else
begin
// Did we get an error or are there no more URLs to crawl?
if (spider.NumUnspidered = ) then
begin
ShowMessage('No more URLs to spider');
end
else
begin
ShowMessage(spider.LastErrorText);
end;
end; // Sleep second before spidering the next URL.
// The reason for waiting a short time before the next fetch is to prevent
// undue stress on the web server. However, if the last page was retrieved
// from cache, there is no need to pause.
if (spider.LastFromCache <> ) then
begin
spider.SleepMs();
end;
end; end;

(Delphi) Using the Disk Cache 使用磁盘缓存的更多相关文章

  1. Android内存优化之磁盘缓存

    前言: 在上一篇文章中介绍了内存缓存,内存缓存的优点就是很快,但是它又有缺点: 空间小,内存缓存不可能很大: 内存紧张时可能被清除: 在应用退出时就会消失,做不到离线: 基于以上的缺点有时候又需要另外 ...

  2. Cache【硬盘缓存工具类(包含内存缓存LruCache和磁盘缓存DiskLruCache)】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 内存缓存LruCache和磁盘缓存DiskLruCache的封装类,主要用于图片缓存. 效果图 代码分析 内存缓存LruCache和 ...

  3. 继续吐槽在net下没有合适的Disk Cache之使用EhCache

    说起缓存,大家可能口若悬河,各种类型的缓存都能一一分析,但在net下找到一款合适的Disk Cache貌似还是有一点难度的. 一:背景 事情是这样的,最近的一个项目中,需要在web端绘制一些报表,因为 ...

  4. linux开启swap(磁盘缓存)操作

    转载 2014年04月26日 14:41:15 4470 由于工作需要,要帮助同事查看linux服务器的缓存开启情况,经过查找资料,可确定通过以下方法确定Linux磁盘缓存是否已开启. 1.命令行下执 ...

  5. form memory cache、form disk cache与304

    200 from memory cache 不访问服务器,直接读缓存,从内存中读取缓存.此时的数据时缓存到内存中的,当kill进程后,数据将不存在200 from disk cache 不访问服务器, ...

  6. from disk cache 与 from memory cache

    webkit资源的分类 webkit的资源分类主要分为两大类:主资源和派生资 http状态码 200 from memory cache 不访问服务器,直接读缓存,从内存中读取缓存.此时的数据时缓存到 ...

  7. Nginx content cache Nginx内容缓存

    原文地址:http://nginx.com/resources/admin-guide/caching/ Nginx content cache Nginx内容缓存 This chapter desc ...

  8. SDWebImage 清除磁盘缓存机制 iOS

    分析的版本 pod 'SDWebImage', '~> 5.0.6' SDWebImage默认清除磁盘缓存的时长是7天. /** * The maximum length of time to ...

  9. android 网络加载图片,对图片资源进行优化,并且实现内存双缓存 + 磁盘缓存

    经常会用到 网络文件 比如查看大图片数据 资源优化的问题,当然用开源的项目  Android-Universal-Image-Loader  或者 ignition 都是个很好的选择. 在这里把原来 ...

随机推荐

  1. arm GIC介绍之一【转】

    转自:https://blog.csdn.net/sunsissy/article/details/73791470 GIC是ARM架构中及其重要的部分,本文只在公开ARM对应资料基础上,以MTK开发 ...

  2. 【坐在马桶上看算法】算法4:队列——解密QQ号

            新学期开始了,小哈是小哼的新同桌(小哈是个小美女哦~),小哼向小哈询问QQ号,小哈当然不会直接告诉小哼啦,原因嘛你懂的.所以小哈给了小哼一串加密过的数字,同时小哈也告诉了小哼解密规则. ...

  3. SharePoint 2013 另一个程序正在使用此文件,进程无法访问。 (异常来自 HRESULT:0x80070020)

    环境:SharePoint 2013 + Windows Server 2012 R2 在管理中心新建一个Web Application,端口为:88.顺利创建网站集后,打开访问却提示:无法显示此页 ...

  4. 为什么要使用断路器Hystrix?

    为什么需要 Hystrix? 在微服务架构中,我们将业务拆分成一个个的服务,服务与服务之间可以相互调用(RPC).为了保证其高可用,单个服务又必须集群部署.由于网络原因或者自身的原因,服务并不能保证服 ...

  5. HTML5 drawImage性能问题

    最近做游戏发现,为了节省HTTP请求,把很多组动画放到了一张图片上,也就是传说中的雪碧图,但是用drawImage从图片上截取一部分绘制在canvas上时会非常慢. 我的图片尺寸为5000*7000 ...

  6. 【AtCoder】ARC090

    C - Candies 前一枚举一个i,求第一行的前i个和第二行从第n个到第i个 代码 #include <bits/stdc++.h> #define fi first #define ...

  7. oracle SQL学习总结

    1.候选键.主键和外键约束: create table Employee( id int primary key, name char(20), birthday Date, address varc ...

  8. spark streaming的容错:防止数据丢失

    官方这么说的 [Since Spark 1.2] Configuring write ahead logs - Since Spark 1.2, we have introduced write ah ...

  9. P1508 Likecloud-吃、吃、吃 DP

    题目背景 问世间,青春期为何物? 答曰:“甲亢,甲亢,再甲亢:挨饿,挨饿,再挨饿!” 题目描述 正处在某一特定时期之中的李大水牛由于消化系统比较发达,最近一直处在饥饿的状态中.某日上课,正当他饿得头昏 ...

  10. ubantu下如何完全彻底卸载mysql(转)

    ubantu下如何完全彻底卸载mysql  https://blog.csdn.net/wszll_Alex/article/details/46277681 第1步  依次执行下面的语句 1 sud ...