DELPHI模拟网页登录 本帖最后由 woai_zhuzhu 于 2012-12-04 00:05:12 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 问题太笼统了1.参考WebBrowser2.参考IdHTTP 求一登录网站的DEMOEDIT1=帐号.txt{文本内容一行一组数字}EDIT2=密码.txt{文本内容一行一组数字}用一按钮来检测文本里面的哪组数字为可登录的帐号和密码。 百度下的時間可能比你發帖子的時間用得還要少。好久前寫的可參考 :http://hi.baidu.com/devhp/item/a581967b7b093f3e7044237e function Login(const Username,Password: string): Boolean;var html :string;begin Result :=False; Account :=UserName; IndyHttp :=TIdHTTP.Create(nil); IndyCookieManager :=TIdCookieManager.Create(nil); IndyHttp.CookieManager :=IndyCookieManager; IndyZlib :=TIdCompressorZLibEx.Create(nil); IndyHttp.Compressor :=IndyZlib; PostParams :=TStringList.Create; IndyHttp.Request.CacheControl :='no-cache'; IndyHttp.Request.Connection :='Keep-Alive'; IndyHttp.Request.Accept :='text/html, application/xhtml+xml, */*'; IndyHttp.Request.ContentType :='application/x-www-form-urlencoded'; IndyHttp.HandleRedirects :=True; IndyHttp.AllowCookies :=True; IndyHttp.HTTPOptions :=[hoForceEncodeParams]; IndyHttp.Get('http://192.168.0.1/Default.aspx'); PostParams.Clear; PostParams.Add('account='+Username); PostParams.Add('password='+Password); IndyHttp.Request.Referer :='Referer http://192.168.0.1/Default.aspx'; html :=IndyHttp.Post('http://192.168.0.1/Login.ashx',PostParams); if Pos('{Userinfo:[{result:"1"}]}',html)>0 then //ajax Result :=True;end; 与网页的验证限制有关的简单的,Twebbrowser控件或idhttpclient控件都可以 用WebBrowser模拟打开登录网页,然后获取指定文本的帐号和密码填入网页的帐号密码输入框。 这个是自动注册的,可以给你做参考 http://blog.csdn.net/sushengmiyan/article/details/8088156 我刚做过一个,用Indy和正则表达式。先Wireshark抓包,分析post的参数如何post进去的。实现是通过Indy登陆系统后模拟post,get,得到源码,统计信息后通过短信发送出去。 谁有做过新浪和腾讯微博的API接口啊? 嵌套式的常量或者结构定义该如何实现(like subdefine<--define<--application) Delphi 二进制导出SQL server Image类型 出错 QQ那样在右下角闪动??? 高分请教!用Delphi如何读取外部进程某固定内存地址的值? 如何把一个字符串写入到缓冲区? 麻烦大家帮我看看 获取某天的百度指数接口。。。 那里有DEPHI 的下载和注册码啊? 请帮帮我!我的SQL Server7运行出错了。 话说现在学Delphi划算么 相减为0时,为啥会出错
1.参考WebBrowser
2.参考IdHTTP
EDIT1=帐号.txt{文本内容一行一组数字}
EDIT2=密码.txt{文本内容一行一组数字}
用一按钮来检测文本里面的哪组数字为可登录的帐号和密码。
var
html :string;
begin
Result :=False;
Account :=UserName;
IndyHttp :=TIdHTTP.Create(nil);
IndyCookieManager :=TIdCookieManager.Create(nil);
IndyHttp.CookieManager :=IndyCookieManager;
IndyZlib :=TIdCompressorZLibEx.Create(nil);
IndyHttp.Compressor :=IndyZlib;
PostParams :=TStringList.Create;
IndyHttp.Request.CacheControl :='no-cache';
IndyHttp.Request.Connection :='Keep-Alive';
IndyHttp.Request.Accept :='text/html, application/xhtml+xml, */*';
IndyHttp.Request.ContentType :='application/x-www-form-urlencoded';
IndyHttp.HandleRedirects :=True;
IndyHttp.AllowCookies :=True;
IndyHttp.HTTPOptions :=[hoForceEncodeParams]; IndyHttp.Get('http://192.168.0.1/Default.aspx'); PostParams.Clear;
PostParams.Add('account='+Username);
PostParams.Add('password='+Password);
IndyHttp.Request.Referer :='Referer http://192.168.0.1/Default.aspx';
html :=IndyHttp.Post('http://192.168.0.1/Login.ashx',PostParams);
if Pos('{Userinfo:[{result:"1"}]}',html)>0 then //ajax
Result :=True;
end;
简单的,Twebbrowser控件或idhttpclient控件都可以
先Wireshark抓包,分析post的参数如何post进去的。
实现是通过Indy登陆系统后模拟post,get,得到源码,统计信息后通过短信发送出去。