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. oracle任务job

    1)创建测试表 1 create table test1(a date); 2)创建存储过程 1 2 3 4 5 create or replace procedure myproc as begin ...

  2. 关于tp5 的验证码遇到的一些问题

    问题1: 网上大部分给的安装包是: composer require topthink/think-captcha 但是会提示你下载失败说要你回复*****的原始数据啥的 那可能是因为你的安装环境版本 ...

  3. nGrinder的安装与使用

    背景 性能压测工具之前使用的是jmeter,这次说的是nGrinder,先直接搬运两者之间的比较 比较点 JMeter nGrinder 结果 实现语言 Java Java = License Apa ...

  4. Grinder搭建小记与Nduja(这次不待续了)

    Grinder是比较有名的浏览器FUZZ框架,采用ruby语言编写,主要是作为测试框架来使用,在<白帽子讲浏览器安全>一书中作者使用了Nduja生成测试样本来配合Grinder使用.根据网 ...

  5. python的mock功能,感觉入门了~~~

    主要实现语法有patch, patch.object, Mock(). 下面的测试太赤裸裸了,只是为了熟悉语法. import unittest from unittest.mock import p ...

  6. [转] Web移动端Fixed布局的解决方案

    移动端业务开发,iOS 下经常会有 fixed 元素和输入框(input 元素)同时存在的情况. 但是 fixed 元素在有软键盘唤起的情况下,会出现许多莫名其妙的问题. 这篇文章里就提供一个简单的有 ...

  7. 【LOJ】#2181. 「SDOI2015」排序

    题解 还以为是啥毒瘤题 然后是个搜索题 复杂度算起来挺大 然后跑起来就连0.1ms不到= = 就是从大到小进行每种操作,搜出来一种操作就乘上一个操作数的阶乘就行 如果现在进行的操作操作\(2^i\)那 ...

  8. 【AtCoder】AGC024

    A - Fairness 如果奇数次是b - a 否则是a - b #include <bits/stdc++.h> #define fi first #define se second ...

  9. 黑苹果 之 神舟战神Z7M-SL7D2

    黑苹果引导工具 Clover 配置详解:http://www.jianshu.com/p/b156b0177a24 神舟Z7m UEFI+GPT安装WIN10+MAC OS X Yosemite双系统 ...

  10. ld: -pie can only be used when targeting iOS 4.2 or later

    ld: -pie can only be used when targeting iOS 4.2 or later clang: error: linker command failed with e ...