用DELPHI可以实现页面表单提交,当点击SUBMIT按妞时,如何能够把提交后的页面源文件显示呢?感谢老师指点。
如http://www.ip138.com/sj/
一个输入框mobile,一个提交按妞submit

解决方案 »

  1.   

    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);
      

  2.   

    IPersistStreamInit;
    提示出错哦
      

  3.   

    我是说点击submit提交后出现的页面啊,谢谢
      

  4.   

    用DELPHI可以实现页面表单提交,当点击SUBMIT按妞时,如何能够把提交后的页面源文件显示呢?感谢老师指点。
    如http://www.ip138.com/sj/
    一个输入框mobile,一个提交按妞submit
      

  5.   

    朋友,提交后的页面是弹出式的页面,你只有让这个页面在Webbrowser中显示都能获得源码
      

  6.   

    为什么不用TIdHTTP去取?就这个网页来说用TIdHTTP很容易的啊。  ParamList := TStringList.Create;
      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;