procedure WB_GetDocumentSourceToStream(Document: IDispatch; Stream: TStream); // Save a TWebbrowser Document to a Stream var PersistStreamInit: IPersistStreamInit; StreamAdapter: IStream; begin Assert(Assigned(Document)); Stream.Size := 0; Stream.Position := 0; if Document.QueryInterface(IPersistStreamInit, PersistStreamInit) = S_OK then begin StreamAdapter := TStreamAdapter.Create(Stream, soReference); PersistStreamInit.Save(StreamAdapter, False); StreamAdapter := nil; end; end;function WB_GetDocumentSourceToString(Document: IDispatch): string; // Save a Webbrowser Document to a string var Stream: TStringStream; begin Result := ''; Stream := TStringStream.Create(''); try WB_GetDocumentSourceToStream(Document, Stream); Result := StringReplace(Stream.Datastring, #$A#9, #$D#$A, [rfReplaceAll]); Result := StringReplace(Result, #$A, #$D#$A, [rfReplaceAll]); finally Stream.Free; end; end;调用 var vsHTML:string; vsHTML:=WB_GetDocumentSourceToString(EmbeddedWB1.Document);
// Save a TWebbrowser Document to a Stream
var
PersistStreamInit: IPersistStreamInit;
StreamAdapter: IStream;
begin
Assert(Assigned(Document));
Stream.Size := 0;
Stream.Position := 0;
if Document.QueryInterface(IPersistStreamInit,
PersistStreamInit) = S_OK then
begin
StreamAdapter := TStreamAdapter.Create(Stream, soReference);
PersistStreamInit.Save(StreamAdapter, False);
StreamAdapter := nil;
end;
end;function WB_GetDocumentSourceToString(Document: IDispatch): string;
// Save a Webbrowser Document to a string
var
Stream: TStringStream;
begin
Result := '';
Stream := TStringStream.Create('');
try
WB_GetDocumentSourceToStream(Document, Stream);
Result := StringReplace(Stream.Datastring, #$A#9, #$D#$A, [rfReplaceAll]);
Result := StringReplace(Result, #$A, #$D#$A, [rfReplaceAll]);
finally
Stream.Free;
end;
end;调用
var vsHTML:string;
vsHTML:=WB_GetDocumentSourceToString(EmbeddedWB1.Document);
提示出错哦
如http://www.ip138.com/sj/
一个输入框mobile,一个提交按妞submit
ParamList.Add('mobile=' + edt1.Text);
ParamList.Add('action=mobile');
ParamList.Add('B1=查 询');
URL := 'http://www.ip138.com:8080/search.asp';
try
mmo1.Lines.Text := idhtp1.Post(URL,ParamList);
except
end;