{Get EleMent Type} function IsSelectElement(eleElement: IHTMLElement): Boolean; function IsPwdElement(eleElement: IHTMLElement): Boolean; function IsTextElement(element: IHTMLElement): boolean; function IsTableElement(element: IHTMLElement): Boolean; function IsElementCollection(element: IHTMLElement): Boolean; function IsChkElement(element: IHTMLElement): boolean; function IsRadioBtnElement(element: IHTMLElement): boolean; function IsMemoElement(element: IHTMLElement): boolean; function IsFormElement(element: IHTMLElement): boolean; function IsIMGElement(element: IHTMLElement): boolean; function IsInIMGElement(element: IHTMLElement): boolean; function IsLabelElement(element: IHTMLElement): boolean; function IsLinkElement(element: IHTMLElement): boolean; function IsListElement(element: IHTMLElement): boolean; function IsControlElement(element: IHTMLElement): boolean; function IsObjectElement(element: IHTMLElement): boolean; function IsFrameElement(element: IHTMLElement): boolean; function IsInPutBtnElement(element: IHTMLElement): boolean; function IsInHiddenElement(element: IHTMLElement): boolean; function IsSubmitElement(element: IHTMLElement): boolean; {Get ImgElement Data} function GetPicIndex(doc: IHTMLDocument2; Src: string; Alt: string): Integer; function GetPicElement(doc: IHTMLDocument2;imgName: string;src: string;Alt: string): IHTMLImgElement; function GetRegCodePic(doc: IHTMLDocument2;ImgName: string; Src: string; Alt: string): TPicture; overload; function GetRegCodePic(doc: IHTMLDocument2;Index: integer): TPicture; overload; function GetRegCodePic(doc: IHTMLDocument2;element: IHTMLIMGElement): TPicture;overload;
constructor TDxHtmlParser.Create; begin CoInitialize(nil); //创建IHTMLDocument2接口 CoCreateInstance(CLASS_HTMLDocument, nil, CLSCTX_INPROC_SERVER, IID_IHTMLDocument2, FHtmlDoc); Assert(FHtmlDoc<>nil,'构建HTMLDocument接口失败'); FHtmlDoc.Set_designMode('On'); //设置为设计模式,不执行脚本 while not (FHtmlDoc.readyState = 'complete') do begin sleep(1); application.ProcessMessages; end; FWebTables := TDxTableCollection.Create(FHtmlDoc); FWebElements := TDxWebElementCollection.Create(nil); FWebComb := TDxWebCombobox.Create(nil); end;
destructor TDxHtmlParser.Destroy; begin FWebTables.Free; FWebElements.Free; FWebComb.Free; CoUninitialize; inherited; end;
function TDxHtmlParser.GetWebCombobox(AName: string): TDxWebCombobox; begin if FWebElements.Collection <> nil then begin FWebComb.CombInterface := FWebElements.ElementByName[AName] as IHTMLSelectElement; Result := FWebComb; end else Result := nil; end;
procedure TDxHtmlParser.SetHTML(const Value: string); begin if FHTML <> Value then begin FHTML := Value; FHtmlDoc.body.innerHTML := FHTML; FWebElements.Collection := FHtmlDoc.all; end; end;