关于网页代码分析的问题~

MyFirst 2003-10-25 07:03:34
我想写一个程序将网页代码中想要的字符串过滤出来.但是不知道从那里下手,那位有这方面的经验或例程让我借鉴下,还有,我应该从那里着手做??

谢谢..
...全文
58 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2003-10-26
  • 打赏
  • 举报
回复
if those tools/libraries are too heavy for you, you can always use regular expressions to extract useful information

Regular Expressions for Delphi
http://www.zeitungsjunge.de/delphi/pcre/index.htm
heartache 2003-10-26
  • 打赏
  • 举报
回复
如果有特定的条件过滤语句,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;
saucer 2003-10-26
  • 打赏
  • 举报
回复
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
MyFirst 2003-10-26
  • 打赏
  • 举报
回复
十分感谢各位的指点,我还有一个问题,就是怎么样才能把自已的信息通过程序登记到网上的供布栏上??(比如我快毕业了,我想写个程序一次把我的个人简历填到各个求职网站上去)
kuchong 2003-10-25
  • 打赏
  • 举报
回复
同意
tanqth 2003-10-25
  • 打赏
  • 举报
回复
up
Spacesoft 2003-10-25
  • 打赏
  • 举报
回复
去google 查一查关于BHO 和IEHelper 的资料,他们是用来做IE 插件的,可以在IE 做动作的时候拦截下下载的网页代码,供你修改。当然,你要有一点COM 的基础。

祝好运。

1,594

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧