delphi获得webbrowser中的html文本
procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate(Edit1.Text);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
doc:olevariant;
str:string;
begin
doc:=WebBrowser1.Document;
//获取元素的值
{str:=doc.all.xx.value;
ShowMessage(str);}
//写入htnl
{doc.clear;
doc.write('<html><head></head><body><p>新的html</p><input type="hidden" value="0" id="xx" /></body></html>');
doc.close;}
//改变元素的值
{doc.all.xx.value:='1';
ShowMessage(doc.all.xx.value);}
//获得html文本
str:=doc.documentElement.outerHtml;
Memo1.Text:=str;
end;
本文来自博客园,作者:IT情深,转载请注明原文链接:https://www.cnblogs.com/wh445306/p/16751854.html