1.delphi 循环采集网页
delphi 循环采集网页
//改了一下您的获取获代码,目前的网页网页估价指导指标源码案例是可以,取到5天的源码超级人类源码资料
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MsXML, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function GetStr(var StrSource:string; StrBegin, StrEnd: string): string;
end;
var
Form1: TForm1;
implementation
{ $R *.dfm}
function TForm1.GetStr(var StrSource:string; StrBegin, StrEnd: string): string;
var
in_star, in_end: integer;
begin
in_star := AnsiPos(strbegin, strsource) + length(strbegin);
in_end := AnsiPos(strend, strsource);
Result := copy(strsource, in_star, in_end - in_star);
if (in_star = 0) or (in_end = 0) or (in_end < in_star) then
StrSource := ''
else
StrSource := copy(strsource, in_end+length(strend), length(strsource))
end;
procedure TForm1.FormCreate(Sender: TObject);
var
req: IXMLHTTPRequest;
SetNoteStr,ResponseStr: string;
begin
req :=CoXMLHTTPRequest.Create;
req.open('Get', '/wap/weather/.shtml', False,EmptyParam, EmptyParam);
req.send(EmptyParam);
memo1.clear;
ResponseStr := req.responseText;
while ResponseStr<>'' do
begin
SetNoteStr := GetStr(ResponseStr, '<dt>', '<br />&');//获取标签直接的代码
memo1.Lines.Add(SetNoteStr);
end;
end;
end.