求教自动向网页填写内容的问题

Module 2010-09-20 12:37:17
某一个asp的网页,控件包括文本框和不可修改的下拉列表框,无验证码,想要实现自动向所有的控件中填写内容,完成后再自动点击提交按钮。

小弟以前是搞CS的,且已不再圈内很多年,所以请各位赐教的时候一定要尽量详细。如有可能,最好是自动打开该网页。
...全文
85 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
q313864740 2011-07-13
  • 打赏
  • 举报
回复
不知道有没有不用WebBrower的方法呢
Module 2010-09-21
  • 打赏
  • 举报
回复
我在第一个页面填写完用户名和密码后登录,这时候会弹出第二个页面,问题是这第二个页面是在IE的新窗口中打开的,我想问,这第二个页面能不能让它在刚才的webBrowser控件中打开,或者在另外一个的一个webBrowser控件中打开?
Module 2010-09-21
  • 打赏
  • 举报
回复
在webBrowser控件中点网页上的提交不好使,根本不能提交,而在IE里面就没有问题。请问这是怎么回事?

或者能不能不通过webBrowser,直接在IE中进行自动添加内容的操作?
wuyq11 2010-09-20
  • 打赏
  • 举报
回复
HtmlElement btnSubmit = webBrowser.Document.All["submitbutton"];
HtmlElement tbUser = webBrowser.Document.All["name"];
HtmlElement tbPass = webBrowser.Document.All["password"];

tbUser.SetAttribute("value", "");
tbPass.SetAttribute("value", "");
btnSubmit.InvokeMember("click");
或使HtmlElementCollection hec= webbrowser.Document.GetElementsByTagName("input");
foreach(HtmlElement he in hec)
i (he.GetAttribute("") == "")
{
he.InvokeMember("click");//按钮
}
  • 打赏
  • 举报
回复
每天回帖即可获得10分可用分!
宝_爸 2010-09-20
  • 打赏
  • 举报
回复
对下列列表赋值

iHTMLEle.SetAttribute("selected", "要选中的值");
参考
http://www.daniweb.com/forums/thread238924.html
宝_爸 2010-09-20
  • 打赏
  • 举报
回复
使用webbrowser控件。
1. 找到控件
HtmlElementCollection forms = webBrowser1.Document.GetElementsByTagName("form");
foreach(HtmlElement form in forms)
{
if (string.Compare(form.GetAttribute("action"), "thanks.php", true) == 0)
{
HtmlElementCollection inputs = form.GetElementsByTagName("input");
foreach (HtmlElement input in inputs)
{
if (string.Compare(input.GetAttribute("type"), "submit", true) == 0)
{
input.InvokeMember("click");
}
}
}
}

2.赋值或者点击
textBox:
iHTMLEle.SetAttribute("value", "testtsteadtadfasdfasdfasdfasdfasdfasdf")
点击按钮:
input.InvokeMember("click");
Module 2010-09-20
  • 打赏
  • 举报
回复
谢谢各位,我先看一下。

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧