打开 http://s.time.org.cn/day/ 显示今天日期.我要把日期取到显示在edit1.text 中. 
 
用IdHTTP 控件 idhttp1.Get() 需要地址的绝对才能取到 ,比如:http://s.time.org.cn/day/xxx.htm .
但现在不知道这个地址默认的打开文件.

解决方案 »

  1.   

    idhttp1.Get('http://s.time.org.cn/day/');
    这样应该可以的
      

  2.   

    idhttp1.Get('http://s.time.org.cn/day/'); 
    应该不可以,你看一下这个页的代码就知道
    我正好昨天刚研究过
    所以说兄弟你碰巧了一个WebBrowser1,一个button1procedure TForm1.Button1Click(Sender: TObject);
    begin
    try
    memo1.Lines.Clear;
    Memo1.Lines.Add(IHtmlDocument2(WebBrowser1.Document).Body.Outertext);
    except
    form1.Caption:='取网页代码失败';
    end;end;
      

  3.   

    var
      StrDownloadInfo: TStringList;
    begin
        StrDownloadInfo := TStringList.Create;
        try
          StrDownloadInfo.Text := utf8toansi(idhttp1.Get('http://s.time.org.cn/day/xxx.htm'));
          ....然后获取要取的值
        finally
          StrDownloadInfo.Free;
        end;    
      

  4.   

    当然你需要先打开一下网页
    button2.clickWebBrowser1.Navigate('http://s.time.org.cn/day/'); //打开地址
      

  5.   

    全部代码如下
    unit1.pas
    ---------------
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, OleCtrls, SHDocVw,mshtml;type
      TForm1 = class(TForm)
        WebBrowser1: TWebBrowser;
        Button1: TButton;
        Edit1: TEdit;
        procedure Button1Click(Sender: TObject);
        procedure WebBrowser1DocumentComplete(Sender: TObject;
          const pDisp: IDispatch; var URL: OleVariant);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
    WebBrowser1.Navigate('http://s.time.org.cn/day/'); //打开地址
    end;procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
      const pDisp: IDispatch; var URL: OleVariant);
    begin
    edit1.Text:=IHtmlDocument2(WebBrowser1.Document).Body.Outertext;end;end.
    -----------------------
    Unit1.dfm
    ----------
    object Form1: TForm1
      Left = 409
      Top = 176
      Width = 424
      Height = 364
      Caption = 'Form1'
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      PixelsPerInch = 96
      TextHeight = 13
      object WebBrowser1: TWebBrowser
        Left = 32
        Top = 16
        Width = 300
        Height = 150
        TabOrder = 0
        OnDocumentComplete = WebBrowser1DocumentComplete
        ControlData = {
          4C000000021F0000810F00000000000000000000000000000000000000000000
          000000004C000000000000000000000001000000E0D057007335CF11AE690800
          2B2E126208000000000000004C0000000114020000000000C000000000000046
          8000000000000000000000000000000000000000000000000000000000000000
          00000000000000000100000000000000000000000000000000000000}
      end
      object Button1: TButton
        Left = 80
        Top = 184
        Width = 75
        Height = 25
        Caption = 'Button1'
        TabOrder = 1
        OnClick = Button1Click
      end
      object Edit1: TEdit
        Left = 48
        Top = 224
        Width = 169
        Height = 21
        TabOrder = 2
        Text = 'Edit1'
      end
    end
      

  6.   

    WebBrowser1 不想用这个东西, 因为我的是dll注入目标程序.用了这个之后,退出注入,目标程就假死很久.好象WebBrowser 没有释放. 如果free掉第二次又获取不到了. 
    之前我也是直接用webbrowser取源代码的.