如何实现在线获取网页的返回值? 我想在程序里实现1、向某个网址发送参数2、获取此网址的返回值3、根据返回值确定程序是否继续执行如何做?使用什么控件?最好给个例子,我是菜鸟 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 WebBrowser 显示网页,模拟点击,获得网页代码,判断......IdHTTP post参数,获得返回信息,判断....其他控件.....idhttp例子:procedure TForm1.Button1Click(Sender: TObject);varpostList: 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);varpostList: 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; 同意楼上,一般用idhttp即可,直接aStr := idhttp.get('http://www.baidu.com')即可返回值就是字符串。不用楼上那么复杂的。 2楼的可以了,不过很多网页都提交的时候都要连cookie一起提交,这个要注意 adoquery多线程编程中关联dbgrid控件时为什么会出现异常??高手进 cxGrid如何显示Blob数据 怎么获取系统的时间? 调用word模版用数据库的值如何替换其中的XX? 请问:如何通过InterBase建立数据库?为什么使用Server菜单栏的"Register"不能注册? 最最基本问题 紧急救助! 用delphi开发进销存软件的问题 一个简单的问题,回应有分! 图形菜单是如何制作的?(用Delphi) 问个加法问题 idhttp post mail163的问题
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;
一般用idhttp即可,直接aStr := idhttp.get('http://www.baidu.com')
即可返回值就是字符串。不用楼上那么复杂的。