我想在程序里实现
1、向某个网址发送参数
2、获取此网址的返回值
3、根据返回值确定程序是否继续执行
如何做?使用什么控件?
最好给个例子,我是菜鸟

解决方案 »

  1.   

    WebBrowser 显示网页,模拟点击,获得网页代码,判断......
    IdHTTP     post参数,获得返回信息,判断....
    其他控件
    .....idhttp例子:procedure TForm1.Button1Click(Sender: TObject);
    var
    postList: TStrings;
    Response: TStringStream;begin;
          Response := TStringStream.Create('');
          postList := TStringList.Create;
          try
              IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon)';
              postList.Add('__EVENTTARGET=');
              postList.Add('__VIEWSTATE=/wEPDwUJLTI5NjAzODk2ZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAQULY2hrUmVtZW1iZXKHW0DW4nQrSrBHBomKrt3/MjtBLA==');
              postList.Add('__EVENTVALIDATION=/wEWBQKE2u7lCQLyj/OQAgK3jsrkBALR55GJDgKC3IeGDO8x1Jd0k/hBY1a/6Yl9fTpP16ti');
              postList.Add('tbUserName=用户名称');
              postList.Add('tbPassword=用户密码');
              postList.Add('chkRemember=');
              postList.Add('btnLogin=登 录');
              IdHTTP1.Post('http://passport.cnblogs.com/login.aspx',postList,Response);//发送参数
          finally
              Memo1.Lines.Text := Utf8ToAnsi(Response.DataString);  //获得返回信息
              Response.Free;
              postList.Free;
          end;end; 简单的登陆站点例子:procedure TForm1.Button1Click(Sender: TObject);
    var
    postList: TStrings;
    Response: TStringStream;
    begin
       Response := TStringStream.Create('');
          postList := TStringList.Create;
          try
              IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon)';
              postList.Add('username=' + edit2.Text);
              postList.Add('password=' + edit3.Text);
              IdHTTP1.Post(Edit1.Text,postList,Response);
          finally
              Memo1.Lines.Text := Response.DataString;
              Response.Free;
              postList.Free;
          end;
    end;
      

  2.   

    同意楼上,
    一般用idhttp即可,直接aStr := idhttp.get('http://www.baidu.com')
    即可返回值就是字符串。不用楼上那么复杂的。
      

  3.   

      2楼的可以了,不过很多网页都提交的时候都要连cookie一起提交,这个要注意