我目前正在开发一个程序,该程序应下载Wikipedia页面的HTML文件,然后将其从HTML转换为PDF。
我的程序到目前为止下载HTML文件,但没有任何图片,页面看起来不完整。
有什么方法可以把INDY包中的idhttp.get组件下载完整的HTML文件?
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdHTTP;
type
TForm3 = class(TForm)
Label1: TLabel;
Button1: TButton;
Button2: TButton;
IdHTTP1: TIdHTTP;
SpeicherEd: TEdit;
SaveDialog1: TSaveDialog;
AuswahlB: TButton;
NameEd: TEdit;
procedure Button1Click(Sender: TObject);
procedure NameEdEnter(Sender: TObject);
procedure AuswahlBClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Speicherort, Form3: TForm3;
implementation
uses
unit2, unit1, Filectrl;
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
var ResponseStream: TFileStream;
begin
ResponseStream := TFileStream.Create(SpeicherEd.Text, fmCreate);
try
idHTTP1.Get(url, ResponseStream);
finally
ResponseStream.Free;
end;
ShowMessage('Download abgeschlossen');
end;
procedure TForm3.AuswahlBClick(Sender: TObject);
var dir : String;
begin
dir := ExtractFilePath(Application.ExeName);
if SelectDirectory ('Bitte ein Verzeichnis auswählen','',Dir)
then
SpeicherEd.Text := (dir+'\'+NameEd.text+'.html');
end;
procedure TForm3.NameEdEnter(Sender: TObject);
begin
NameEd.Text := '';
end;
end.