如果有特定的条件过滤语句,pageproducer就很不错(不知道是不是这样拼写)就用过一次
如果想读取table等里的内容,放到stringgrid等里,就必须熟练pos,copy函数.
还有就是mshtml的IHTMLElementCollection,它可以轻松读取代码中的元素集,然后运用到code中
下面提供一个html解析器的代码,把代码转换成定义(不知道如何解释,用一用就知道了)
procedure HTMLParser(Source,Target:TStrings);
var i,j:integer;
s:String;
ws:wideString;
InCmd,InStr,CmdOK:boolean;
CmdType,StrType:String;
CmdData,StrData:String;
Data:String;
begin
Target.Clear;
InCmd:=false;
InStr:=False;
CmdOk:=false;
CmdType:='';
StrType:='';
CmdData:='';
StrData:='';
data:='';
for i:=0 to source.count-1 do
begin
ws:=source[i];
for j:=1 to length(ws) do
begin
s:=ws[j];
if s<' ' then continue;
if InCmd then
begin
if InStr then
begin
if s=StrType then
begin
CmdData:=CmdData+StrType+StrData+StrType;
InStr:=False;
StrType:='';
StrData:='';
end
else
begin
StrData:=StrData+s;
end;
end
else if (s='"') or (s='''') then
begin
InStr:=True;
StrData:='';
StrType:=s;
end
else if s='>' then
begin
Target.add('<'+CmdType+' '+CmdData+'>');
InCmd:=false;
CmdType:='';
CmdData:='';
CmdOk:=false;
end
else if not CmdOK then
begin
if s=' ' then
begin
CmdOK:=True;
CmdData:='';
end
else
begin
CmdType:=CmdType+s;
end;
end
else
begin
CmdData:=CmdData+s;
end;
end
else
begin
if s='<' then
begin
if data<>'' then target.add(data);
data:='';
InCmd:=true;
CmdType:='';
CmdData:='';
CmdOk:=false;
end
else
begin
data:=data+s;
end;
end;
end;
end;
if data<>'' then target.add(data);
end;
that is a little complicated, since these web sites don't provide standard programmatic interface like a web service, the best you can do is to extract the post form format (<form ..><input type=...>...</form>) from these sites, and set these fields programmatically, then do a HTTP POST. But it may not be worth your time to do that, you may as well do it manually