本文整理自网络,侵删。
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses System.SysUtils, System.Classes, System.Net.HttpClient, System.RegularExpressions;
const url = 'http://www.delphitop.com/';varmatchs: TMatchCollection;m: TMatch;begin var http := THttpClient.Create; var sl := TStringList.Create;
try sl.LoadFromStream(http.Get(url).ContentStream, TEncoding.ANSI);
matchs := TRegEx.Matches(sl.Text, '<span>(?<price>(\d+[,.])*\d+)</span>');for m in matchs dobeginwriteln('获取信息: ', m.Groups.Item['price'].Value);end;
Readln; finally sl.Free; http.Free; end;end.
相关阅读 >>
Delphi中操作olevariant、variant和stream
Delphi tstringlist utf8编码保存并开启bom
Delphi 利用 showmessage(syserrormessage(getlasterror));得到不反馈的错误信息
更多相关阅读请进入《Delphi》频道 >>