用以下方法可以得到网页中的内容!
procedure GetData;
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i,j: integer;
vi: OleVariant;
IE1: IWebBrowser2;
IDoc1: IHTMLDocument2;
iELC : IHTMLElementCollection ;
S2 : string;
HtmlInputEle : IHTMLInputElement;
begin
ShellWindow := CoShellWindows.Create;
nCount := ShellWindow.Count;
for i := 0 to nCount - 1 do
begin
vi := i;
spDisp := ShellWindow.Item(vi);
if spDisp = nil then continue;
spDisp.QueryInterface( iWebBrowser2, IE1 );
if IE1 <> nil then
begin
IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);
if iDoc1 <> nil then
begin
ielc:=idoc1.Get_all;
for j:=0 to ielc.length-1 do
begin
Application.ProcessMessages;
spDisp := ielc.item(J, 0);
if SUCCEEDED(spDisp.QueryInterface(IHTMLInputElement ,HtmlInputEle))then
with HtmlInputEle do
begin
S2:=Type_;
S2:=UpperCase(S2);
if (StrComp(PChar(S2),'TEXT')=0) or (StrComp(PChar(S2),'PASSWORD')=0) then
form1.ListBox1.Items.Add(value);//value就是索要获得的内容了
end;
end;
end;
end;
end;
end;