问题描述
- C#实例化一个firefox模型问题
-
我想知道C#可以通过: SHDocVw.InternetExplorer IE = new InternetExplorer();实例化一个IE模型,然后可以抓取页面元素,模拟IE的各种行为,以下是模拟登陆代码(请不要说通过post,post返回的cookie是临时cookie)
但是C#可不可以实例化一个firefox或者chrome模型,然后像下面代码一样在firefox浏览器中模拟以下行为呢?SHDocVw.InternetExplorer IE = new InternetExplorer(); IE.Visible = true; string URL = ""; object nullArg = null; IE.Navigate(URL, ref nullArg, ref nullArg, ref nullArg, ref nullArg); while (IE.Busy || IE.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE) Thread.Sleep(1000); //得到IE的文档对象模型 mshtml.IHTMLDocument2 DOM = (mshtml.IHTMLDocument2)IE.Document; //声明用户 mshtml.IHTMLInputTextElement txtUserName = (mshtml.IHTMLInputTextElement)DOM.all.item("id", null); txtUserName.value = id; //密码 mshtml.IHTMLInputTextElement txtUserPwd = (mshtml.IHTMLInputTextElement)DOM.all.item("pw", null); txtUserPwd.value = pwd; //登录 mshtml.HTMLInputElement btnLogin = (mshtml.HTMLInputElement)DOM.all.item("login_btn", 0); btnLogin.click(); System.Threading.Thread.Sleep(1000);
谢谢大家!!!
解决方案
解决方案二:
http://download.csdn.net/download/xiaoyunaa/3411907
时间: 2024-11-03 17:25:48