¾È³çÇϼ¼¿ä? ¸Å¹ø µµ¿ò¸¸ ¹Þ´Ù°¡ Çѹø ¿Ã·Áº¾´Ï´Ù.
ÀͽºÇ÷η¯ ȸ鿡¼ HTMLÀ» ºÒ·¯´Ù µ¥ÀÌÅ͸¦ ã¾Æ ÀúÀåÇϴµ¥ Á¤ÀÛ ¿øÇÏ´Â ³»¿ëÀÌ È¸é¿£ º¸À̴µ¥ HTML Source¿¡ º¸ÀÌÁö ¾Ê¾Æ ¾Ö¸¦ ¸Ô°íÀÖ´Ù°¡ ÇÑ È¸é¿¡ FrameÀÌ ¿©·¯°³ Àִٴ°ÍÀ» ¾Ë°ÔµÇ¾ú½À´Ï´Ù. ¸ðµç FrameÀÇ HTML Source¸¦ Frameº°·Î ÀúÀåÇÕ´Ï´Ù.
Compiler : Delphi 7
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, StdCtrls, OleCtrls, OleServer, mshtml, SHDocVw, ActiveX, ComCtrls, ComObj, Clipbrd;
type TForm1 = class(TForm) Label1: TLabel; Label2: TLabel; Edit1: TEdit; Button1: TButton; Memo1: TMemo; procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1; TempDateS,DateS: string;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); begin TempDateS := FormatDateTime('yyyymmddhhmmss', Now); DateS := Copy(TempDateS,1,8); Edit1.Text := 'www.korea.com'; end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := caFree; Form1 := nil; end;
procedure TForm1.Button1Click(Sender: TObject); var i,x: integer; URL,iStr: string; IE: Variant; Frame: IDispatch; FrameDoc: IHTMLDocument2; begin IE := CreateOleObject('InternetExplorer.Application'); IE.Visible := true; URL := Edit1.Text; IE.Navigate(URL); while IE.Busy do sleep(500); sleep(1000);
x := IE.Document.Frames.Length; if x > 0 then begin for i := 0 to (x - 1) do begin iStr := IntToStr(i); Frame := IE.Document.Frames.Item(i); FrameDoc := (Frame as IHTMLWindow2).Document as IHTMLDocument2; Memo1.Text := FrameDoc.Get_body.Get_outerHTML; Memo1.Lines.SaveToFile('WebPage_'+iStr+'_'+TempDateS+'.txt'); end; end; IE.Quit; ShowMessage('HTML documents in frames have been saved.'); end;
end.
|