这是个html文件<body topmargin="0">
<title>网页标题</title>
<table width=100% cellspacing=0 cellpadding=0>
<tr>
<td class=inputcontent>
<table width=100% cellspacing=0 cellpadding=0 class=TBborder>
<tr class=TBtitle style="height:19;padding:2px 2px">
<td style="font-size:12px" align=left>如何获取到 网页标题 并保存为 网页标题.html
<title>网页标题</title>
<table width=100% cellspacing=0 cellpadding=0>
<tr>
<td class=inputcontent>
<table width=100% cellspacing=0 cellpadding=0 class=TBborder>
<tr class=TBtitle style="height:19;padding:2px 2px">
<td style="font-size:12px" align=left>如何获取到 网页标题 并保存为 网页标题.html
你可以参考 Search & Replace这个软件。
假设文件的内容已被读入一字符串 htmfunction getTitle(const htm: string):string;
var p1,p2:cardinal;
begin
p1 := pos('<title>',htm);
p2 := pos('</title>',htm);
if (p1>0) and (p2>p1) then
result := copy(htm,p1 + 7,p2-p1 - 7)
else
result := '';
end;把取得的字符串写入文件名当然,更复杂的匹配,就需要正则表达式了.