procedure TCrawlingThread.WBDocumentComplete(Sender: TObject ;
const pDisp:IDispatch;
var URL: OLEVariant);
var
i:Integer;
ElementCollection: IHTMLElementCollection;
HtmlElement: IHTMLElement;
AnchorString:
string;
sl:TStringList;
begin
try
if Assigned((FWB.Document
as IHTMLDocument2).body)
then
begin
sl:=TStringList.Create;
try
sl.Text := ((FWB.Document
as IHTMLDocument2).body
as IHTMLBodyElement).createTextRange.text;
sl.SaveToFile(IncludeTrailingBackSlash(FFilePath) + FGuid);
finally
sl.Free;
end;
end;
ElementCollection:= (FWB.Document
as IHTMLDocument2).all;
For i := 0
To ElementCollection.length - 1
do
begin
HtmlElement := ElementCollection.item(I, '
')
as IHTMLElement;
if HTMLElement.tagName = '
A'
then
begin
AnchorString := (HtmlElement
as IHTMLAnchorElement).href;
FCollectedLinks.Add(AnsiLowerCase(AnchorString));
end;
end;
FCanTerminate := true;
except
on E:
Exception do FError := E.
Message;
end;
end;