var IdHTTP1:Tidhttp; MyStreamt:TMemoryStream; jp:TJpegImage; begin MyStreamt:=TMemoryStream.Create; { ou tout autre TStream } Try IdHTTP1:=Tidhttp.Create(nil); Try IdHTTP1.Get('http://www.developpez.biz/images/Favicon.ico',Mystreamt); except ShowMessage('Fichier indisponible'); Exit; End; Mystreamt.Seek(0, soFromBeginning); { on rembobine le stream } jp:=TJpegImage.Create; Try jp.LoadFromStream(MyStreamt); Image1.Picture.Icon(jp); Finally jp.free; End; Finally IdHTTP1.Free; MyStreamt.Free; End; end;
procedure TForm1.WebBrowserDocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant); var IdHTTP1: Tidhttp; MyStreamt: TMemoryStream; jp: TIcon; lien, Source: string; SL: TStringList; position: integer; begin ComboBox3.Text := tWebBrowser(pagecontrol1.ActivePage.Controls[0]).LocationURL; pagecontrol1.ActivePage.Caption := tWebBrowser(pagecontrol1.ActivePage.Controls[0]).LocationName; pagecontrol1.ActivePage.Hint := tWebBrowser(pagecontrol1.ActivePage.Controls[0]).LocationURL; if ComboBox3.Text <> 'about:blank' then begin MyStreamt := TMemoryStream.Create; { ou tout autre TStream } IdHTTP1 := Tidhttp.Create(nil); lien := StringReplace(ComboBox3.Text, 'http://www.', '', [rfReplaceAll]); lien := StringReplace(lien, 'www.', '', [rfReplaceAll]); SL := TStringList.Create; SL.Text := StringReplace(lien, '/', #13#10, [rfReplaceAll]); Source := tWebBrowser(pagecontrol1.ActivePage.Controls[0]).OleObject.Document.all.tags('HEAD').item(0).innerHTML; Source := Copy(Source, Pos('<LINK rel="shortcut icon" ', Source), Length(Source) - Pos('<LINK rel="shortcut icon" ', Source)); Source := Copy(Source, Pos('href="', Source) + 6, Length(Source) - 6); Source := Copy(Source, 0, Pos('.ico', Source) - 1); if (Length(Source) < 20) and (Length(Source)<>0) then begin IdHTTP1.Get('http://www.' + SL[0] + Source + '.ico', Mystreamt); SL.free; Mystreamt.Seek(0, soFromBeginning); { on rembobine le stream } jp := TIcon.Create; try jp.LoadFromStream(MyStreamt); Icone.InsertIcon(Icone.Count, jp); finally jp.free; end; IdHTTP1.Free; MyStreamt.Free; pagecontrol1.ActivePage.ImageIndex := (Icone.Count - 1); end; end; end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionRécupèrer tous les liens d'une page Web
var i:Integer;
begin
for i:=0 to Webbrowser1.OleObject.Document.links.Length-1 do
Listbox1.Items.Add(Webbrowser1.OleObject.Document.Links.Item(i));
end;
Enregistrer une page Web
WebBrowser1.ExecWB(OLECMDID_SAVEAS,OLECMDEXECOPT_DODEFAULT);