(Delphi) Using the Disk Cache 使用磁盘缓存
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 使用磁盘缓存的更多相关文章
- Android内存优化之磁盘缓存
前言: 在上一篇文章中介绍了内存缓存,内存缓存的优点就是很快,但是它又有缺点: 空间小,内存缓存不可能很大: 内存紧张时可能被清除: 在应用退出时就会消失,做不到离线: 基于以上的缺点有时候又需要另外 ...
- Cache【硬盘缓存工具类(包含内存缓存LruCache和磁盘缓存DiskLruCache)】
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 内存缓存LruCache和磁盘缓存DiskLruCache的封装类,主要用于图片缓存. 效果图 代码分析 内存缓存LruCache和 ...
- 继续吐槽在net下没有合适的Disk Cache之使用EhCache
说起缓存,大家可能口若悬河,各种类型的缓存都能一一分析,但在net下找到一款合适的Disk Cache貌似还是有一点难度的. 一:背景 事情是这样的,最近的一个项目中,需要在web端绘制一些报表,因为 ...
- linux开启swap(磁盘缓存)操作
转载 2014年04月26日 14:41:15 4470 由于工作需要,要帮助同事查看linux服务器的缓存开启情况,经过查找资料,可确定通过以下方法确定Linux磁盘缓存是否已开启. 1.命令行下执 ...
- form memory cache、form disk cache与304
200 from memory cache 不访问服务器,直接读缓存,从内存中读取缓存.此时的数据时缓存到内存中的,当kill进程后,数据将不存在200 from disk cache 不访问服务器, ...
- from disk cache 与 from memory cache
webkit资源的分类 webkit的资源分类主要分为两大类:主资源和派生资 http状态码 200 from memory cache 不访问服务器,直接读缓存,从内存中读取缓存.此时的数据时缓存到 ...
- Nginx content cache Nginx内容缓存
原文地址:http://nginx.com/resources/admin-guide/caching/ Nginx content cache Nginx内容缓存 This chapter desc ...
- SDWebImage 清除磁盘缓存机制 iOS
分析的版本 pod 'SDWebImage', '~> 5.0.6' SDWebImage默认清除磁盘缓存的时长是7天. /** * The maximum length of time to ...
- android 网络加载图片,对图片资源进行优化,并且实现内存双缓存 + 磁盘缓存
经常会用到 网络文件 比如查看大图片数据 资源优化的问题,当然用开源的项目 Android-Universal-Image-Loader 或者 ignition 都是个很好的选择. 在这里把原来 ...
随机推荐
- ajax请求成功但不执行success-function回调函数的问题
在success:function(data){}下面加个error:function(){},看看是不是出错了走了error.如果是,说明返回值类型不符合要求. 比如:下面代码返回String类型. ...
- 你会使用super()吗?你确定你了解它吗?
我们经常在类的继承当中使用super(), 来调用父类中的方法.例如下面: class A: def func(self): print('OldBoy') class B(A): def func( ...
- windows安装 Microsoft Visual c++
第一种方法: 第二种方法: 参考链接 直接给一个2015版本的下载地址 https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/un ...
- laravel的启动过程解析
laravel的启动过程,也是laravel的核心,对这个过程有一个了解,有助于得心应手的使用框架,希望能对大家有点帮助. 统一入口 laravel框架使用了统一入口,入口文件:/public/ind ...
- JavaScriptSerializer中日期序列化解决方案
后台代码: JavaScriptSerializer _jsSerializer = new JavaScriptSerializer(); ViewBag.ProcName = ProcInst.P ...
- 使用div模拟出frameset效果
<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" > <head> < ...
- SSIS组件——Merge、Merge Join、Union All
- Anaconda完全入门指南
Anaconda完全入门指南 参考文章: 致Python初学者:Anaconda入门使用指南 Anaconda使用总结 概述 很多学习python的初学者甚至学了有一段时间的人接触到anaconda或 ...
- 005.MySQL双主-Master01可用配置
[root@Master01 ~]# vim /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_de ...
- Spring Security + JWT实现前后端分离权限认证
现在国内前后端很多公司都在使用前后端分离的开发方式,虽然也有很多人并不赞同前后端分离,比如以下这篇博客就很有意思: https://www.aliyun.com/jiaocheng/650661.ht ...