鹤
鹤起风云
Unregistered / Unconfirmed
GUEST, unregistred user!
var
这样的代码总是不行!
TextFileName: string;
procedure TMainForm.OpenUrlBtnClick(Sender: TObject);
var
FileAttrs, i: Integer;
searchRec: TsearchRec;
HtmlName, mainpath: string;
begin
mainpath:= 'E:/html/';
if FindFirst(mainpath+'*.htm',FileAttrs, SearchRec)=0 then
begin
HtmlName:= mainpath+SearchRec.Name;
TextFileName:= Copy(HtmlName, 1, strlen(pchar(HtmlName))-3)+'txt';
WebBrowser.Navigate(HtmlName);
while FindNext(SearchRec) = 0do
begin
HtmlName:= mainpath+SearchRec.Name;
TextFileName:= Copy(HtmlName, 1, strlen(pchar(HtmlName))-3)+'txt';
WebBrowser.Navigate(HtmlName);
end;
FindClose(SearchRec);
end;
end;
procedure TMainForm.WebBrowserDocumentComplete(Sender: TObject;
const pDisp: IDispatch;
var URL: OleVariant);
var
buffer: string;
DataFile: TFileStream;
HTMLDocument: IHTMLDocument2;
begin
HTMLDocument := WebBrowser.Document as IHTMLDocument2;
DataFile:= TFileStream.Create(TextFileName, fmCreate);
strlen(pchar(HTMLDocument.body.innerText));
buffer:= HTMLDocument.body.innerText;
DataFile.Write(buffer, strlen(pchar(buffer)));
DataFile.Free;
end;
如果改成就可以?
procedure TMainForm.OpenUrlBtnClick(Sender: TObject);
begin
WebBrowser.Navigate(UrlEdit.Text);
end;
procedure TMainForm.SaveAsBtnClick(Sender: TObject);
var
HTMLDocument: IHTMLDocument2;
begin
HTMLDocument := WebBrowser.Document as IHTMLDocument2;
Memo1.Text := HTMLDocument.body.innerText;
end;
这样的代码总是不行!
TextFileName: string;
procedure TMainForm.OpenUrlBtnClick(Sender: TObject);
var
FileAttrs, i: Integer;
searchRec: TsearchRec;
HtmlName, mainpath: string;
begin
mainpath:= 'E:/html/';
if FindFirst(mainpath+'*.htm',FileAttrs, SearchRec)=0 then
begin
HtmlName:= mainpath+SearchRec.Name;
TextFileName:= Copy(HtmlName, 1, strlen(pchar(HtmlName))-3)+'txt';
WebBrowser.Navigate(HtmlName);
while FindNext(SearchRec) = 0do
begin
HtmlName:= mainpath+SearchRec.Name;
TextFileName:= Copy(HtmlName, 1, strlen(pchar(HtmlName))-3)+'txt';
WebBrowser.Navigate(HtmlName);
end;
FindClose(SearchRec);
end;
end;
procedure TMainForm.WebBrowserDocumentComplete(Sender: TObject;
const pDisp: IDispatch;
var URL: OleVariant);
var
buffer: string;
DataFile: TFileStream;
HTMLDocument: IHTMLDocument2;
begin
HTMLDocument := WebBrowser.Document as IHTMLDocument2;
DataFile:= TFileStream.Create(TextFileName, fmCreate);
strlen(pchar(HTMLDocument.body.innerText));
buffer:= HTMLDocument.body.innerText;
DataFile.Write(buffer, strlen(pchar(buffer)));
DataFile.Free;
end;
如果改成就可以?
procedure TMainForm.OpenUrlBtnClick(Sender: TObject);
begin
WebBrowser.Navigate(UrlEdit.Text);
end;
procedure TMainForm.SaveAsBtnClick(Sender: TObject);
var
HTMLDocument: IHTMLDocument2;
begin
HTMLDocument := WebBrowser.Document as IHTMLDocument2;
Memo1.Text := HTMLDocument.body.innerText;
end;