如何用.NET摸拟网页提交?
怎么样在.NET中用winform实现站点的登陆并获取登陆后的页面信息?有验证码的.
------解决方案--------------------可以,我们公司一个哥们就是专门做这个的.
首先诉你是可以的,
用System.Net.WebRequest模拟网页登录.
返回一个System.Net.WebResponse.
要等到验证码,就要从返回的结果中分析页面中的图片的路径再读取出来 .
验证码一般都是这样的 <image src= 'yanzhengma.aspx ' /> 你就要返回的页面中找到这个 "yanzhengma.aspx "的位置,
还有一点,还要保持与目标站点的SESSION ,其实 asp.net 的SESSION 是与 cookies 中的 aspnetsession 有关系的, JSP中的是 与一个名为 JSESSION 的COOKIES有关的,
保持SESSION ,其实也就是你把目录网站写到客户端的SESSION 等到并在下次提交的时候返回去.
------解决方案--------------------WebBrowser
CSDN以前就有个WINFORM的访问工具带源码的
你找找看
------解决方案--------------------HTMLDocument doc = webBrowser3.Document.DomDocument as HTMLDocument;
HtmlWindow window = webBrowser3.Document.Window.Frames[0];
doc = window.Document.DomDocument as HTMLDocument;
HTMLInputElementClass input = doc.all.item( "username ", 0) as HTMLInputElementClass;
input.value = username;
input = doc.all.item( "passwd ", 0) as HTMLInputElementClass;
input.value = passwd;
input = doc.all.item( "rmNum ", 0) as HTMLInputElementClass;
input.value = rmNum;
input = doc.all.item( "Submit ", 0) as HTMLInputElementClass;
input.click();
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
HTMLDocument d11 = webBrowser1.Document.DomDocument as HTMLDocument;
HtmlWindow window11 = webBrowser1.Document.Window.Frames[1];
d11 = window11.Document.DomDocument as HTMLDocument;
HTMLInputElementClass input11 = d11.all.item( "txtUserID ", 0) as HTMLInputElementClass;
input11.value = username;
input11 = d11.all.item( "txtPassword ", 0) as HTMLInputElementClass;
input11.value = passwd;
input11 = d11.all.item( "vCode ", 0) as HTMLInputElementClass;
input11.value = rmNum;
input11 = d11.all.item( "btnLogin ", 0) as HTMLInputElementClass;
input11.click();
以上是模拟提交。