【急切求助】如何在“西祠论坛”自动发帖、回帖(请大家讨论)? 大家好啊!我想请教一个问题:如何在“西祠论坛”自动发帖、回帖(请大家讨论)?该论坛登陆只需要输入用户名和密码,没有验证码。对这方面比较好奇,就想和大家讨论一下。请对这方面熟悉的朋友介绍一下,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 后院自动发帖代码(C#版)******************引用地址http://spark.cjlu.edu.cn/bbs/viewthread.php?tid=15630&extra=&page=1******************RT,网上泛滥的论坛自动发帖机器人,俺也比划着写了一个vs2005 c#.net2.0具体程序界面还没有完成,爱生活,爱后院作类已经差不多写好code:///有几个地方没有弄好,一是cookie的处理,需要将Domain的.spark.cjlu.edu.cn改为spark.cjlu.edu.cn,不知为何;二是discuz的formhash机制还没有搞清楚///另:有python/perl高手的话可以指导我一下,我在FC5,PYTHON2.5下老是没有搞好那个cookiejar,无法模拟发帖class Robot{/// attributes// cookiesprivate CookieCollection CkCollection = null;// request and responseprivate HttpWebRequest SparkRequest = null;private HttpWebResponse SparkResponse = null;// some urlprivate string LoginUrl = null;private string ReplyUrl = null;// constructerpublic Robot(){CkCollection = new CookieCollection();}// loginingpublic string Login(string url, string usr,string pass){string Return = null;this.LoginUrl = url;// may be I should add a functin for create stringstring loginstr = "formhash=3bd8bc0a&referer=index.php&loginmode=&styleid=&cookietime=2592000&loginfield=username&username=" + usr;loginstr += "&password=" + pass;loginstr += "&questionid=0&answer=&loginsubmit=提 交";loginstr = EncodePost(loginstr);byte[] replybyte = Encoding.UTF8.GetBytes(loginstr);try{CookieContainer sparkc = new CookieContainer();SparkRequest = (HttpWebRequest)WebRequest.Create(url);SparkRequest.CookieContainer = sparkc;SparkRequest.ContentType = "application/x-www-form-urlencoded";SparkRequest.Method = "POST";SparkRequest.ContentLength = replybyte.Length;Stream newStream = SparkRequest.GetRequestStream();newStream.Write(replybyte, 0, replybyte.Length);newStream.Close();SparkResponse = (HttpWebResponse)SparkRequest.GetResponse();Stream dataStream = SparkResponse.GetResponseStream();StreamReader reader = new StreamReader(dataStream, Encoding.GetEncoding("gb2312"));Return = reader.ReadToEnd();// check cookieforeach (Cookie temp in SparkResponse.Cookies){if (temp.Domain != "spark.cjlu.edu.cn")temp.Domain = "spark.cjlu.edu.cn";}CkCollection = SparkResponse.Cookies;}catch{return null;}return Return;}// overload/*public bool Login(string usr, string pass){;}*/// reply……public string Reply(string url,string formhash,string title,string content){SparkRequest = (HttpWebRequest)WebRequest.Create("http://spark.cjlu.edu.cn/bbs/"+url);SparkRequest.ContentType = "application/x-www-form-urlencoded";SparkRequest.Method = "POST";//SparkRequest.Referer = "http://spark.cjlu.edu.cn/bbs/index.php";SparkRequest.KeepAlive = true;SparkRequest.AllowWriteStreamBuffering = false;// set cookieCookieContainer cookieCon = new CookieContainer();SparkRequest.CookieContainer = cookieCon;SparkRequest.CookieContainer.Add(CkCollection);// get post valuestring reply = EncodePost("formhash=" + formhash + "&subject=&usesig=1&message=" + content);byte[] replybyte = Encoding.UTF8.GetBytes(reply);SparkRequest.ContentLength = replybyte.Length;Stream newStream = SparkRequest.GetRequestStream();newStream.Write(replybyte, 0, replybyte.Length);newStream.Close();// get responseSparkResponse = (HttpWebResponse)SparkRequest.GetResponse();Stream dataStream = SparkResponse.GetResponseStream();StreamReader reader = new StreamReader(dataStream, Encoding.GetEncoding("gb2312"));string tt = reader.ReadToEnd();reader.Close();dataStream.Close();SparkResponse.Close();return tt;}// encode the post stringprivate string EncodePost(string input){string output = null;Char[] reserved = { '?', '=', '&' };if (input != null){int i = 0, j;while (i < input.Length){j = input.IndexOfAny(reserved, i);if (j == -1){output = output + HttpUtility.UrlEncode(input.Substring(i, input.Length - i), System.Text.Encoding.GetEncoding("gb2312"));break;}string tt = HttpUtility.UrlEncode(input.Substring(i, j - i), System.Text.Encoding.GetEncoding("gb2312"));output += tt;output += input.Substring(j, 1);i = j + 1;}return output;}elsereturn null;}} 用WF开发是,出现了这个错误是什么原因? 反序列化,为空 关于将c编写的exe文件放入资源文件中动态调用 TranslateTransform问题 注册插件 各位帮帮忙,dataGrid中用户调整列头宽度后,怎样获得调整后的宽度值(再线等) 用程序写出ID的自增! 高手请入,请问,如何实现c++程序和c#写的web service 之间的长连接的?? C# 浏览器 关闭 放大功能 vs 2008与vs 2005有什么区别? 请你把一组数转化成人民币大写,例如1234.56转化成壹千贰百三拾四元五角六分 计算机三级 机试c的运行环境
引用地址
http://spark.cjlu.edu.cn/bbs/viewthread.php?tid=15630&extra=&page=1
******************RT,网上泛滥的论坛自动发帖机器人,俺也比划着写了一个
vs2005 c#.net2.0
具体程序界面还没有完成,爱生活,爱后院作类已经差不多写好
code:///有几个地方没有弄好,一是cookie的处理,需要将Domain的.spark.cjlu.edu.cn改为spark.cjlu.edu.cn,不知为何;二是discuz的formhash机制还没有搞清楚///另:有python/perl高手的话可以指导我一下,我在FC5,PYTHON2.5下老是没有搞好那个cookiejar,无法模拟发帖class Robot
{
/// attributes
// cookies
private CookieCollection CkCollection = null;
// request and response
private HttpWebRequest SparkRequest = null;
private HttpWebResponse SparkResponse = null;
// some url
private string LoginUrl = null;
private string ReplyUrl = null;// constructer
public Robot()
{
CkCollection = new CookieCollection();
}// logining
public string Login(string url, string usr,string pass)
{
string Return = null;
this.LoginUrl = url;
// may be I should add a functin for create string
string loginstr = "formhash=3bd8bc0a&referer=index.php&loginmode=&styleid=&cookietime=2592000&loginfield=username&username=" + usr;
loginstr += "&password=" + pass;
loginstr += "&questionid=0&answer=&loginsubmit=提 交";
loginstr = EncodePost(loginstr);
byte[] replybyte = Encoding.UTF8.GetBytes(loginstr);try
{
CookieContainer sparkc = new CookieContainer();
SparkRequest = (HttpWebRequest)WebRequest.Create(url);
SparkRequest.CookieContainer = sparkc;
SparkRequest.ContentType = "application/x-www-form-urlencoded";
SparkRequest.Method = "POST";SparkRequest.ContentLength = replybyte.Length;
Stream newStream = SparkRequest.GetRequestStream();
newStream.Write(replybyte, 0, replybyte.Length);
newStream.Close();SparkResponse = (HttpWebResponse)SparkRequest.GetResponse();
Stream dataStream = SparkResponse.GetResponseStream();
StreamReader reader = new StreamReader(dataStream, Encoding.GetEncoding("gb2312"));
Return = reader.ReadToEnd();// check cookie
foreach (Cookie temp in SparkResponse.Cookies)
{
if (temp.Domain != "spark.cjlu.edu.cn")
temp.Domain = "spark.cjlu.edu.cn";
}CkCollection = SparkResponse.Cookies;
}
catch
{
return null;
}
return Return;
}// overload
/*
public bool Login(string usr, string pass)
{
;
}*/// reply……
public string Reply(string url,string formhash,string title,string content)
{
SparkRequest = (HttpWebRequest)WebRequest.Create("http://spark.cjlu.edu.cn/bbs/"+url);
SparkRequest.ContentType = "application/x-www-form-urlencoded";
SparkRequest.Method = "POST";
//SparkRequest.Referer = "http://spark.cjlu.edu.cn/bbs/index.php";
SparkRequest.KeepAlive = true;
SparkRequest.AllowWriteStreamBuffering = false;// set cookie
CookieContainer cookieCon = new CookieContainer();
SparkRequest.CookieContainer = cookieCon;
SparkRequest.CookieContainer.Add(CkCollection);// get post value
string reply = EncodePost("formhash=" + formhash + "&subject=&usesig=1&message=" + content);
byte[] replybyte = Encoding.UTF8.GetBytes(reply);
SparkRequest.ContentLength = replybyte.Length;
Stream newStream = SparkRequest.GetRequestStream();
newStream.Write(replybyte, 0, replybyte.Length);
newStream.Close();// get response
SparkResponse = (HttpWebResponse)SparkRequest.GetResponse();
Stream dataStream = SparkResponse.GetResponseStream();
StreamReader reader = new StreamReader(dataStream, Encoding.GetEncoding("gb2312"));
string tt = reader.ReadToEnd();reader.Close();
dataStream.Close();
SparkResponse.Close();return tt;
}// encode the post string
private string EncodePost(string input)
{
string output = null;
Char[] reserved = { '?', '=', '&' };
if (input != null)
{
int i = 0, j;
while (i < input.Length)
{
j = input.IndexOfAny(reserved, i);
if (j == -1)
{
output = output + HttpUtility.UrlEncode(input.Substring(i, input.Length - i), System.Text.Encoding.GetEncoding("gb2312"));
break;
}
string tt = HttpUtility.UrlEncode(input.Substring(i, j - i), System.Text.Encoding.GetEncoding("gb2312"));
output += tt;
output += input.Substring(j, 1);
i = j + 1;
}
return output;
}
else
return null;
}
}