众所周知,urlmon是一个简单易用的爬虫
调用方法:
在代码的开头加上uses urlmon;
内部函数:URLDownloadToFile(nil,网址,下载到哪里,0,nil);
例如爬取洛谷用户空间的代码:
uses
urlmon;
var
i:longint;
s:ansistring;
begin
for i:=1 to 100000 do
begin
str(i,s);
URLDownloadToFile(nil,Pchar('https://www.luogu.org/space/show?uid='+s),Pchar('users_space\'+s+'.html'),0,nil);
writeln('Website https://www.luogu.org/space/show?uid='+s,' ',i,' has downloaded to ',s+'.html');
end;
end.