菜
菜鸟黄
Unregistered / Unconfirmed
GUEST, unregistred user!
我是这样做的,但这只是适用于输入框数据的获取.
//获得数据
Procedure ReadData(WebBrowser: TWebBrowser; IsPost: Boolean; Memo:TMemo;Label1:TLabel);
Var
i: Integer;
vi: oleVariant;
Dispatch: IDispatch;
HTMLDocument: IHTMLDocument2;
ElementCollection: IHTMLElementCollection;
HTMLInputElement: IHTMLInputElement;
Begin
HTMLDocument := IHTMLDocument2(WebBrowser.Document);
If HTMLDocument = Nil Then Exit;
ElementCollection := HTMLDocument.all;
For i := 0 To ElementCollection.Length - 1 Do
Begin
vi := i;
application.ProcessMessages;
Dispatch := ElementCollection.item(vi, 0);
If Succeeded(Dispatch.QueryInterface(IHTMLInputElement, HTMLInputElement)) Then
Begin
Memo.Lines.Add(HTMLInputElement.name);
If LowerCase(HTMLInputElement.value) = usernameA Then
begin
Label1.Caption:= HTMLInputElement.value;
end;
End; {For}
End;
End;
//获得数据
Procedure ReadData(WebBrowser: TWebBrowser; IsPost: Boolean; Memo:TMemo;Label1:TLabel);
Var
i: Integer;
vi: oleVariant;
Dispatch: IDispatch;
HTMLDocument: IHTMLDocument2;
ElementCollection: IHTMLElementCollection;
HTMLInputElement: IHTMLInputElement;
Begin
HTMLDocument := IHTMLDocument2(WebBrowser.Document);
If HTMLDocument = Nil Then Exit;
ElementCollection := HTMLDocument.all;
For i := 0 To ElementCollection.Length - 1 Do
Begin
vi := i;
application.ProcessMessages;
Dispatch := ElementCollection.item(vi, 0);
If Succeeded(Dispatch.QueryInterface(IHTMLInputElement, HTMLInputElement)) Then
Begin
Memo.Lines.Add(HTMLInputElement.name);
If LowerCase(HTMLInputElement.value) = usernameA Then
begin
Label1.Caption:= HTMLInputElement.value;
end;
End; {For}
End;
End;