Moj program ma
wchodzic na strone www.xxx.pl i wyssietlac/zapisywac zawartosc kazdej ramki sie tam znajdujacej najlepiej jak by to robil zaraz po wczytaniu strony
Ogolnie juz mi to dziala ale nie do konca a mianowicie
- jesli na stronce jest przekierowanie to wyswietla mi tylko glowna 1 ramke
- gdy jednak omine przekierowanie i wejde na strone www.yyy.pl to mi dziala zapisywanie ramek jednak po tej operacji twebbrowser odmawia wspolpracy tz jak klikne na stronce jakis butom to wyswietla mi sie pusta stronka :(
moj kod
procedure TMainForm.Button2Click(Sender: TObject);
begin
SaveWBFrames(Webbrowser1);
end;
function TMainForm.SaveWBFrames(WebBrowser1: TWebBrowser): string;
var
Webdoc, HTMLDoc: ihtmldocument2;
framesCol: iHTMLFramesCollection2;
FramesLen: integer;
pickFrame: olevariant;
p: integer;
begin
try
WebDoc := WebBrowser1.Document as IHTMLDocument2;
Result := GetFrameSource(WebDoc);
// §§§ Hier kann Result in eine Datei gespeichert werden §§§§ oder mit
WB_SaveFrameToFile(WebDoc,'c:\MainPage.html');
//Handle multiple or single frames
FramesCol := WebDoc.Get_frames;
FramesLen := FramesCol.Get_length;
if FramesLen > 0 then
for p := 0 to FramesLen - 1 do
begin
pickframe := p;
HTMLDoc := WebBrowser1.Document as iHTMLDocument2;
WebDoc := GetBrowserForFrame(HTMLDoc, pickframe).document as iHTMLDocument2;
if WebDoc <> nil then
begin
Result := GetFrameSource(WebDoc);
// §§§ Hier kann Result in eine Datei gespeichert werden §§§§ oder mit
WB_SaveFrameToFile(WebDoc, 'c:\Frame' + IntToStr(p) + '.html');
// Wie bekommt man den Namen für ein Frame ??
// so?
// ShowMessage(HTMLDoc.Get_parentWindow.Get_name);
// ShowMessage(HTMLDoc.Get_parentWindow.Parent.Get_document.nameProp);
end;
end;
except
Result := 'No Source Available';
end;
end;
function TMainForm.WB_SaveFrameToFile(HTMLDocument: IHTMLDocument2;
const FileName: TFileName): Boolean;
var
PersistFile: IPersistFile;
begin
PersistFile := HTMLDocument as IPersistFile;
PersistFile.Save(StringToOleStr(FileName), System.True);
end;