我要把百度的相关关键词抓取下来。不明白的就开下面这个地址
http://d.baidu.com/rs.php?q=delphi+%B2%D9%D7%F7ini%CE%C4%BC%FE&tn=baidu
下面显示的关键词我要他显示在我的软件上如(listbox)里面,如何操作。急,谢谢高手了。。
http://d.baidu.com/rs.php?q=delphi+%B2%D9%D7%F7ini%CE%C4%BC%FE&tn=baidu
下面显示的关键词我要他显示在我的软件上如(listbox)里面,如何操作。急,谢谢高手了。。
得到网页源码
之后使用正则表达式获取里面的内容
在d7中需要第三方正则表达式单元文件
例子,wait....
源码:www.ftpff.com/CC_UPFiles/mycgb.rar
里面的HyperLinksDecorator.pas和RegExpr.pas是正则表达式类,不用看主要代码:
uses RegExpr;//正则表达式单元procedure TForm1.GetKey;
const BaiDuKey = 'baidur>(.[^<]*)';
var
MyR: TRegExpr;
begin
MyR := TRegExpr.Create;
ListBox1.Items.Clear;
try
MyR.Expression := BaiDuKey;
if MyR.Exec(Memo1.Text) then
while MyR.ExecNext do
begin
ListBox1.Items.Add(MyR.Match[1]);
end;
finally
MyR.Free;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
try
Memo1.Lines.Clear;
Memo1.Lines.Add(IdHTTP1.Get(Edit1.Text));
GetKey;
except
ShowMessage('获取源码出错');
end;
end;
邮箱是[email protected]
只用MSN