我想写一个程序将网页代码中想要的字符串过滤出来.但是不知道从那里下手,那位有这方面的经验或例程让我借鉴下,还有,我应该从那里着手做??谢谢..
解决方案 »
- 关于cxgrid和行列转换的问题,高人赐教!
- 要表一查出所有数据,表二根据条件查询,然后在同一个数据集中显示出来,如何实现?
- 急!!!!!!!!!!!!!!!!!!!在线!!!!!
- 不结帖的理由!欢迎讨论,兼散分!
- 怎样动态加入图片?
- 超难度的SQL语句, 要求不用存储过程. 就是sql 语句. 170 高分
- 获焦点问题?
- ADO中事务的问题
- 从一个文本文件中读取字符,如何判断是英文字符,还是中文字符,还是其他字符?
- 第三方的所有控件换成了D5标准控件,为什么还是'IDE not fount,Please register'?
- 求一个相片集中关于相片的排列算法,
- 怎样将adoquery查询后的记录,单击后保存或输出为excel文件!!急!要实例!给分!
如果想读取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;
http://www.zeitungsjunge.de/delphi/pcre/index.htm