WinForm : 利用webBrowser完成填充数据并 自动登陆某网站。。。。。。。
2011-11-08 20:54
441 查看
private void tse_Load(object sender, EventArgs e)
{
//this.webBrowser1.Navigate("http://www.sina.com.cn/");
this.webBrowser1.IsWebBrowserContextMenuEnabled = true;
}
//此按钮登陆新浪邮箱。。。。。。。。。测试通过。
private void button2_Click(object sender, EventArgs e)
{
HTMLDocument doc = webBrowser1.Document.DomDocument as HTMLDocument;
//<input name="u" id="u" type="text" onfocus="shy_clear()"/>登录名
HTMLInputElementClass input = doc.all.item("u", 0) as HTMLInputElementClass;
input.value = "lin833";
//<input name="psw" id="psw" type="password"/>密码
input = doc.all.item("psw", 0) as HTMLInputElementClass;
input.value = "33333333";
//<input type="submit" value="登录" onclick="return log_submit();" align="absmiddle"/>登录
//<form name="login" method="post" action="">
webBrowser1.Document.InvokeScript("log_submit");
HTMLFormElementClass form = doc.all.item("login", 0) as HTMLFormElementClass;
form.submit();
}
//**************************************此例程用于登陆网站首页存在框架集
private void button3_Click(object sender, EventArgs e)
{
HTMLDocument doc = webBrowser1.Document.DomDocument as HTMLDocument;
HtmlWindow window = webBrowser1.Document.Window.Frames[0];
doc = window.Document.DomDocument as HTMLDocument;
HTMLInputElementClass input = doc.all.item("username", 0) as HTMLInputElementClass;
input.value = "000";
input = doc.all.item("passwd", 0) as HTMLInputElementClass;
input.value = "000";
//input = doc.all.item("rmNum", 0) as HTMLInputElementClass;
//input.value = doc.getElementById("intImg").innerHTML.ToString();
//input.value = "2222";
input = doc.all.item("Submit", 0) as HTMLInputElementClass;
input.click();
}
private void button4_Click(object sender, EventArgs e)
{
if (this.webBrowser1.ReadyState.ToString() == "Complete")
{
//获取自动登陆后,进入规则页,再继续做点击转到默认加载页。。。
HTMLDocument child = webBrowser1.Document.DomDocument as HTMLDocument;
HtmlWindow window_2 = webBrowser1.Document.Window.Frames[0];
child = window_2.Document.DomDocument as HTMLDocument;
//HTMLInputElementClass input = child.all.item("gtype", 0) as HTMLInputElementClass;
//input.value = "FT";
HTMLInputElementClass input = child.all.item("submit", 1) as HTMLInputElementClass;
input.value = "我同意";
input.click();
}
}
=====================================================
this.Flag = "sdfa";
////this.Close();
//this.DialogResult = DialogResult.OK;
//this.Close();
this.UserName = this.textBox1.Text.Trim(); //"1877";
this.Password = "bb12345";
this.rmNum = this.textBox3.Text;
string strPostData = String.Format("uid=&langx=gb&username={0}&passwd={1}&rmNum={2}&SS={3}&SR={4}&TS={5}&&Submit=%E7%A1%AE%E8%AE%A4"
, this.UserName
, this.Password
, this.rmNum
, this.SS
, this.SR
, this.TS
);
this.webBrowser1.AllowNavigation= true;
this.webBrowser1.AllowWebBrowserDrop = true;
//string kksdf = "uid=&langx=gb&SS=5812344&SR=3807085320&TS=4984716874&username=dpk1877&passwd=a12345&rmNum=2979&Submit=%E7%A1%AE%E8%AE%A4";
string strHeaders = "Content-Type: application/x-www-form-urlencoded\r\n";
ASCIIEncoding AE = new ASCIIEncoding();
byte[] bytePost = AE.GetBytes(strPostData);
byte[] byteHeaders = AE.GetBytes(strHeaders);
object vPost = bytePost;
object vHeaders = byteHeaders;
string tag =null;
webBrowser1.Navigate("http://080.com/app/member/login.php", tag, bytePost, strHeaders);
//webBrowser1.Navigate("http://080.com/app/member/chk_rule.php");
this.webBrowser1.AllowNavigation = true;
//axWebBrowser1.
//object o = null;
//object o1 = System.Text.Encoding.ASCII.GetBytes(strPostData);
//object o2 = "Content-Type: application/x-www-form-urlencoded\r\n"; //必须要加的
//axWebBrowser1.Navigate("http://080.com/app/member/login.php", ref o, ref o, ref o1, ref o2);
//this.webBrowser1.Navigate("http://080.com/app/member/login.php", ref o, ref o1, ref o2);
////*************************思归...
//object vFlags = null;
//object vTarget = null;
////string strData = "username=MyName&password=MyPassword";
//string strHeaders = "Content-Type: application/x-www-form-urlencoded\r\n";
//ASCIIEncoding AE = new ASCIIEncoding();
//byte[] bytePost = AE.GetBytes(strPostData);
//byte[] byteHeaders = AE.GetBytes(strHeaders);
//object vPost = bytePost;
//object vHeaders = byteHeaders;
//// POST the data
//axWebBrowser1.Navigate("http://080.com/app/member/login.php", ref vFlags, ref vTarget, ref vPost, ref vHeaders);
{
//this.webBrowser1.Navigate("http://www.sina.com.cn/");
this.webBrowser1.IsWebBrowserContextMenuEnabled = true;
}
//此按钮登陆新浪邮箱。。。。。。。。。测试通过。
private void button2_Click(object sender, EventArgs e)
{
HTMLDocument doc = webBrowser1.Document.DomDocument as HTMLDocument;
//<input name="u" id="u" type="text" onfocus="shy_clear()"/>登录名
HTMLInputElementClass input = doc.all.item("u", 0) as HTMLInputElementClass;
input.value = "lin833";
//<input name="psw" id="psw" type="password"/>密码
input = doc.all.item("psw", 0) as HTMLInputElementClass;
input.value = "33333333";
//<input type="submit" value="登录" onclick="return log_submit();" align="absmiddle"/>登录
//<form name="login" method="post" action="">
webBrowser1.Document.InvokeScript("log_submit");
HTMLFormElementClass form = doc.all.item("login", 0) as HTMLFormElementClass;
form.submit();
}
//**************************************此例程用于登陆网站首页存在框架集
private void button3_Click(object sender, EventArgs e)
{
HTMLDocument doc = webBrowser1.Document.DomDocument as HTMLDocument;
HtmlWindow window = webBrowser1.Document.Window.Frames[0];
doc = window.Document.DomDocument as HTMLDocument;
HTMLInputElementClass input = doc.all.item("username", 0) as HTMLInputElementClass;
input.value = "000";
input = doc.all.item("passwd", 0) as HTMLInputElementClass;
input.value = "000";
//input = doc.all.item("rmNum", 0) as HTMLInputElementClass;
//input.value = doc.getElementById("intImg").innerHTML.ToString();
//input.value = "2222";
input = doc.all.item("Submit", 0) as HTMLInputElementClass;
input.click();
}
private void button4_Click(object sender, EventArgs e)
{
if (this.webBrowser1.ReadyState.ToString() == "Complete")
{
//获取自动登陆后,进入规则页,再继续做点击转到默认加载页。。。
HTMLDocument child = webBrowser1.Document.DomDocument as HTMLDocument;
HtmlWindow window_2 = webBrowser1.Document.Window.Frames[0];
child = window_2.Document.DomDocument as HTMLDocument;
//HTMLInputElementClass input = child.all.item("gtype", 0) as HTMLInputElementClass;
//input.value = "FT";
HTMLInputElementClass input = child.all.item("submit", 1) as HTMLInputElementClass;
input.value = "我同意";
input.click();
}
}
=====================================================
this.Flag = "sdfa";
////this.Close();
//this.DialogResult = DialogResult.OK;
//this.Close();
this.UserName = this.textBox1.Text.Trim(); //"1877";
this.Password = "bb12345";
this.rmNum = this.textBox3.Text;
string strPostData = String.Format("uid=&langx=gb&username={0}&passwd={1}&rmNum={2}&SS={3}&SR={4}&TS={5}&&Submit=%E7%A1%AE%E8%AE%A4"
, this.UserName
, this.Password
, this.rmNum
, this.SS
, this.SR
, this.TS
);
this.webBrowser1.AllowNavigation= true;
this.webBrowser1.AllowWebBrowserDrop = true;
//string kksdf = "uid=&langx=gb&SS=5812344&SR=3807085320&TS=4984716874&username=dpk1877&passwd=a12345&rmNum=2979&Submit=%E7%A1%AE%E8%AE%A4";
string strHeaders = "Content-Type: application/x-www-form-urlencoded\r\n";
ASCIIEncoding AE = new ASCIIEncoding();
byte[] bytePost = AE.GetBytes(strPostData);
byte[] byteHeaders = AE.GetBytes(strHeaders);
object vPost = bytePost;
object vHeaders = byteHeaders;
string tag =null;
webBrowser1.Navigate("http://080.com/app/member/login.php", tag, bytePost, strHeaders);
//webBrowser1.Navigate("http://080.com/app/member/chk_rule.php");
this.webBrowser1.AllowNavigation = true;
//axWebBrowser1.
//object o = null;
//object o1 = System.Text.Encoding.ASCII.GetBytes(strPostData);
//object o2 = "Content-Type: application/x-www-form-urlencoded\r\n"; //必须要加的
//axWebBrowser1.Navigate("http://080.com/app/member/login.php", ref o, ref o, ref o1, ref o2);
//this.webBrowser1.Navigate("http://080.com/app/member/login.php", ref o, ref o1, ref o2);
////*************************思归...
//object vFlags = null;
//object vTarget = null;
////string strData = "username=MyName&password=MyPassword";
//string strHeaders = "Content-Type: application/x-www-form-urlencoded\r\n";
//ASCIIEncoding AE = new ASCIIEncoding();
//byte[] bytePost = AE.GetBytes(strPostData);
//byte[] byteHeaders = AE.GetBytes(strHeaders);
//object vPost = bytePost;
//object vHeaders = byteHeaders;
//// POST the data
//axWebBrowser1.Navigate("http://080.com/app/member/login.php", ref vFlags, ref vTarget, ref vPost, ref vHeaders);
相关文章推荐
- WinForm : 利用webBrowser完成填充数据并 自动登陆某网站。。。。。。。
- C#自动给据sql中的带@的变量提取变量名称在从简单数据对象中取得生成SqlParameter数组进行数据插入(利用反射完成)
- C#自动给据sql中的带@的变量提取变量名称在从简单数据对象中取得生成SqlParameter数组进行数据插入(利用反射完成)
- 熙熙-C#-webBrowser-登录-数据填充-模拟点击链接-运行JS函数-检测网页是否载入完成
- 利用post实现对一些网站的自动登陆
- 利用FTP和计划任务自动备份网站数据和数据库
- 黑客利用网页自动填充功能导流至恶意网站
- 网站自动登陆、数据下载问题!紧急求助
- 利用临时数据表完成SQL语句输出并进行自动编号
- MFC利用webbrowser控件实现简单的自动登陆
- C#-webBrowser-登录-数据填充-模拟点击链接-运行JS函数-检测网页是否载入完成
- 利用webBrowser来实现自动登录网站
- C# winform的WebBrowser自动登录某网站
- 利用Adapter对象将数据填充到DataTable(或DataSet)的例子
- c# 实现网页上用户自动登陆|asp.net 模拟网站登录
- shell自动备份网站数据到百度网盘
- 在.net中利用webbrowser控件实现WinForm与WebForm交互2
- php模拟post提交数据,用处很多,可用来网站的采集,登陆等等
- 使用WebBrowser自动登录阿里妈妈网站
- C# webBrowser 模拟登陆填充操作等(写网页注册机之类的时候要用到)