如何用.NET摸拟网页提交? 怎么样在.NET中用winform实现站点的登陆并获取登陆后的页面信息?有验证码的. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用System.Net.WebRequest模拟网页登录.返回一个System.Net.WebResponse.有验证码的.如果是图片,那就难搞了.你得用专业的分析工具,但也不一定能分析正确. 用System.Net.WebRequest模拟网页登录.返回一个System.Net.WebResponse.有验证码的.如果是图片,那就难搞了.你得用专业的分析工具,但也不一定能分析正确. 用System.Net.WebRequest模拟网页登录.返回一个System.Net.WebResponse.有验证码的.如果是图片,那就难搞了.你得用专业的分析工具,但也不一定能分析正确. 直接用web写,把winform当作一个皮肤,把web浏览器嵌入到winform中 可以,我们公司一个哥们就是专门做这个的.首先诉你是可以的,用System.Net.WebRequest模拟网页登录.返回一个System.Net.WebResponse.要等到验证码,就要从返回的结果中分析页面中的图片的路径再读取出来 .验证码一般都是这样的 <image src='yanzhengma.aspx' /> 你就要返回的页面中找到这个"yanzhengma.aspx"的位置,还有一点,还要保持与目标站点的SESSION ,其实 asp.net 的SESSION 是与 cookies 中的 aspnetsession 有关系的, JSP中的是 与一个名为 JSESSION 的COOKIES有关的,保持SESSION ,其实也就是你把目录网站写到客户端的SESSION 等到并在下次提交的时候返回去. 还有一点,yanzhengma.aspx中的返回的其实是一个二进制的流,你只要把它显示成图片就OK了. zbw911在返回的页面流中找到图片的二进制流部分? WebBrowserCSDN以前就有个WINFORM的访问工具带源码的你找找看 主要的技术在于验证码识别模拟提交可以使用WebRequest或者WebClient都可以具体可以参考 CSDN论坛助手 if (this.webBrowser1.ReadyState.ToString() == "Complete") { HTMLDocument dvc = this.webBrowser1.Document.DomDocument as HTMLDocument; HTMLDocument sd = this.webBrowser1.Document.DomDocument as HTMLDocument; HtmlWindow windowf = webBrowser1.Document.Window.Frames[1]; dvc = windowf.Document.DomDocument as HTMLDocument; foreach (IHTMLImgElement x in dvc.images) { if (x.src.IndexOf("inc/GetCode.asp") > -1) { imgRange = (IHTMLControlRange)body.createControlRange(); imgRange.add((IHTMLControlElement)x); imgRange.execCommand("Copy", false, null); bmp = (Bitmap)Clipboard.GetDataObject().GetData(DataFormats.Bitmap); //bmp.Save(@"now_12.bmp"); } }}+++++++++++++++++++++++++++++++++++++++++++++++++++很简单的,把验证码页判断并另存为二进制流或图片都成,偶的代码里有,楼主改改就用。不过偶访问的网址是框架集,所以获取this.webBrowser1.Document的时候要区别一下。 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();以上是模拟提交。 Fooo(四月·我爱我妻) 非常感谢!!!我去试 Font到底是什么? 如何使用C#将Word的窗口提到使用状态? C#中的datagridview winform问题 如何使按钮不执行onClick里面的语句?(十万火急!!!!!!!!!) 存储过程的使用方法 中间层用哪种技术合适? 线程键操作无效:从不是创建控件xx的线程访问它 大家讨论一下关于分页算法的问题? c#能够象VB。NET那样伸缩数组吗? 一个和java当中同样的功能,请问在c#当中如何实例,等待中............. 小问题 发分
首先诉你是可以的,
用System.Net.WebRequest模拟网页登录.
返回一个System.Net.WebResponse.
要等到验证码,就要从返回的结果中分析页面中的图片的路径再读取出来 .验证码一般都是这样的 <image src='yanzhengma.aspx' /> 你就要返回的页面中找到这个"yanzhengma.aspx"的位置,
还有一点,还要保持与目标站点的SESSION ,其实 asp.net 的SESSION 是与 cookies 中的 aspnetsession 有关系的, JSP中的是 与一个名为 JSESSION 的COOKIES有关的,
保持SESSION ,其实也就是你把目录网站写到客户端的SESSION 等到并在下次提交的时候返回去.
在返回的页面流中找到图片的二进制流部分?
CSDN以前就有个WINFORM的访问工具带源码的
你找找看
模拟提交可以使用WebRequest或者WebClient都可以
具体可以参考 CSDN论坛助手
if (this.webBrowser1.ReadyState.ToString() == "Complete")
{
HTMLDocument dvc = this.webBrowser1.Document.DomDocument as HTMLDocument;
HTMLDocument sd = this.webBrowser1.Document.DomDocument as HTMLDocument;
HtmlWindow windowf = webBrowser1.Document.Window.Frames[1];
dvc = windowf.Document.DomDocument as HTMLDocument;
foreach (IHTMLImgElement x in dvc.images)
{
if (x.src.IndexOf("inc/GetCode.asp") > -1)
{
imgRange = (IHTMLControlRange)body.createControlRange();
imgRange.add((IHTMLControlElement)x);
imgRange.execCommand("Copy", false, null);
bmp = (Bitmap)Clipboard.GetDataObject().GetData(DataFormats.Bitmap);
//bmp.Save(@"now_12.bmp");
}
}}+++++++++++++++++++++++++++++++++++++++++++++++++++很简单的,把验证码页判断并另存为二进制流或图片都成,偶的代码里有,楼主改改就用。
不过偶访问的网址是框架集,所以获取this.webBrowser1.Document的时候要区别一下。
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();
以上是模拟提交。
非常感谢!!!我去试