如何取得网页超级链接所指的页面上的所有文字并显示在memo中,举个例子吧,当你上了
csdn之后,你怎么样在delphi程序中取得第一个问题的超级链接所指的页面上的文字,
而不用打开新的网页?

解决方案 »

  1.   

    可以使用delphi 6里的NMHTTP组件可以做到。
      

  2.   

    TO: goldvale(不败) 
    有详细说明吗?
      

  3.   


    procedure TForm1.FormCreate(Sender: TObject);
    begin
    nmhttp1.InputFileMode:=true;
    nmhttp1.TimeOut:=2000;
    nmhttp1.Body:='part.tmp';
    nmhttp1.Header:='head.tmp';
    edit3.PasswordChar:='*';
    progressbar1.Min:=0;
    progressbar1.Max:=100;
    progressbar1.Position:=0;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    nmhttp1.HeaderInfo.UserId:=edit2.text;
    nmhttp1.HeaderInfo.Password:=edit3.Text;
    nmhttp1.Get(edit1.text);
    end;procedure TForm1.NMHTTP1AuthenticationNeeded(Sender: TObject);
    begin
    showmessage('need authentication at this server');
    end;procedure TForm1.NMHTTP1Connect(Sender: TObject);
    begin
    statusbar1.SimpleText:='connected';
    end;procedure TForm1.NMHTTP1Failure(Cmd: CmdType);
    begin
    statusbar1.SimpleText:='failed';
    end;procedure TForm1.NMHTTP1ConnectionFailed(Sender: TObject);
    begin
    statusbar1.SimpleText:='connecte failed';
    end;procedure TForm1.NMHTTP1Success(Cmd: CmdType);
    var
      fname:string;
      buf:string;
      pnewfile,poldfile:pchar;
      i:integer;
    begin
    statusbar1.SimpleText:='file save to :'+nmhttp1.Body;
    fname:=nmhttp1.Body;
    for i:=length(edit1.Text) downto 1 do
      if edit1.Text[i]<>'/' then
        begin
        buf:=edit1.Text[i]+buf;
      end
      else
        break;
      getmem(poldfile,length(fname)+1);
      strpcopy(poldfile,fname);
      getmem(pnewfile,length(buf)+1);
      strpcopy(pnewfile,buf);
      movefile(poldfile,pnewfile);
      freemem(poldfile);
      freemem(pnewfile);
      statusbar1.SimpleText:='download complete';
      label2.Caption:=fname;
      label3.caption:=buf;
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
    nmhttp1.Get(edit1.text);
    end;procedure TForm1.NMHTTP1PacketRecvd(Sender: TObject);
    begin
    progressbar1.Position:=round(nmhttp1.BytesRecvd/nmhttp1.BytesTotal)*100;
    end;
    看一下吧。