WebBrowser中比较棘手的问题(自动登录),请各位指点,一定高分

solly solly 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我利用WebBrowser做一个浏览器。要求能够自动登陆,要求能够自动连接页面。要求能够自动的将页面中的表格中的数据自动保存下来。
自动登陆部分我在http://www.163.com中测试可以通过,但在包含有框架页中就无法实现自动登陆的功能。
下面是困扰我几天的问题,大家看看我的代码问题出在哪个地方。同时希望高手们为我调试一下。
我需要自动登陆的页面 http://stbet.com

procedure TForm1.LoginFrameset(document: IHTMLDocument2);
var
index: Integer;
ole_index: OleVariant;
frame_dispatch: IDispatch;
framed: IHTMLWindow2;
obj_user : Olevariant;
obj_pass : Olevariant;
obj_submit : Olevariant;
begin
if document = nil then
exit;
try
for index := 1 to document.Frames.Length do
try
ole_index := index-1;
frame_dispatch := document.Frames.Item(ole_index);

obj_user := document.all.item('username',0);
obj_user.value := 'username'; //今后用户名从配置文件中取
obj_pass := document.all.item('passwd',0);
obj_pass.value := '0000'; //今后密码在配置文件中取
obj_submit := document.all.item('Submit2',0);
obj_submit.Click;

if frame_dispatch <> nil then
begin
framed := frame_dispatch as IHTMLWindow2;
NavigateFrameset(framed.document);
end;
except
on E: Exception do
begin
end
end;
except
on E: Exception do
begin
Application.MessageBox(PChar(E.Message),
PChar('Exception'));
end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
LoginFrameset(WebBrowser1.Document as IHTMLDocument2);
end;

...全文

相关推荐

评论 12
收藏 已收藏
分享
返回顶部
solly
Windows SDK/API 1,184 成员 22,326 内容