procedure TForm1.Button3Click(Sender: TObject); var str1:tstrings; substr,substr1:string; i :integer; txtfile:textfile; begin assignfile(txtfile,'c:\yyy.txt'); reset(txtfile); Rewrite(txtfile); str1:=tstringlist.Create;str1.LoadFromFile('c:\yyy.htm'); for i:=1 to str1.Count do begin substr:=str1[i]; //showmessage(inttostr(pos('>',substr))); substr1:=copy(substr,pos('>',substr)+1,pos('<',substr)-pos('>',substr)-1); writeln(txtfile,substr1); end;
加一句 CloseFile(txtfile);
for i:=1 to str1.Count do 要改成: for i:=0 to str1.Count-1 do
var
str1:tstrings;
substr,substr1:string;
i :integer;
txtfile:textfile;
begin
assignfile(txtfile,'c:\yyy.txt');
reset(txtfile);
Rewrite(txtfile);
str1:=tstringlist.Create;str1.LoadFromFile('c:\yyy.htm');
for i:=1 to str1.Count do
begin
substr:=str1[i];
//showmessage(inttostr(pos('>',substr)));
substr1:=copy(substr,pos('>',substr)+1,pos('<',substr)-pos('>',substr)-1);
writeln(txtfile,substr1); end;
CloseFile(txtfile);
要改成:
for i:=0 to str1.Count-1 do
比如链接、文本、图片等等。
呵呵,这样是不可以的。
要用到MSHTML_tlb