|
网上已经有不少DISCUZ论坛的自动登录发贴程序,但基本上只能针对特定论坛,因为DISCUZ在每次发帖时均会变更FORMHASH防注册发帖机,本人也试了不少办法来突破这一点,最简单的就是利用WEBBROWSER控件,闲话不多说,代码如下,需要完整采集器及发贴机代码的请与本人联系:QQ435809415- string cookie="";
- private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
- {
- try
- {
- //cookie = GetCookie(e.Url.ToString());
- cookie= textBox29.Text;
- HttpHelper http=new HttpHelper();
- HttpItem item = new HttpItem()
- {
- URL = webBrowser1.Url.AbsoluteUri,//URL
- Method = "Get",//URL 可选项 默认为Get
- Cookie = cookie,//调用webBrowser1登陆的cookie
- ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
- };
- HttpResult result = http.GetHtml(item);
- string html = result.Html;
- textBox30.Text= Regex.Match(result.Html, @"(?<=formhash=)\w+").Value;
- textBox29.Text=cookie ;
- }
- catch
- {
- }
- }
复制代码 |
|