110,533
社区成员
发帖
与我相关
我的任务
分享
</script><script type="text/javascript" reload="1">
display('loginfield_selectinput');
display('loginform');
pagescroll.right(2);
$('messageleft').innerHTML = '<h1>欢迎您回来 新兵 tempUser</h1>';
$('messageright').innerHTML = '<h1><a href="javascript:;" onclick="location.reload()">如果该页面长时间没有响应,请点这里刷新</a></h1>';
setTimeout('location.reload()', 3000);
floatwinreset = 1;
</script>
</div>
</div></div></div>
</div>
void LoginBtnClick(object sender, EventArgs e)
{
Encoding coder=Encoding.GetEncoding("utf-8");
string str="formhash=8c44a714&loginfield=username&username="+
userText.Text+"&password="+passText.Text+
"&questionid=0&answer=&loginsubmit=true";
byte[] postByte=coder.GetBytes(str);
HttpWebRequest hwq=(HttpWebRequest)WebRequest.Create("http://bbs.egou.com");
hwq.Method="POST";
hwq.ContentType="keep-alive";
hwq.Accept="application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
hwq.UserAgent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.237 Safari/534.10";
hwq.Referer="http://bbs.egou.com/logging.php?action=login";
hwq.RequestUri.
hwq.ContentLength=postByte.Length;
Stream postStream=hwq.GetRequestStream();
postStream.Write(postByte,0,postByte.Length);
WebResponse wrp=hwq.GetResponse();
Stream receiveStream=wrp.GetResponseStream();
StreamReader reader=new StreamReader(receiveStream,Encoding.GetEncoding("gb2312"));
string s=string.Empty;
while(!reader.EndOfStream){
s+=reader.ReadLine();
Application.DoEvents();
}
richTextBox1.AppendText(s);
}
<?xml version="1.0" encoding="gbk"?><root><![CDATA[<script type="text/javascript" reload="1">
var nopermst
</script>
<div>
<h3 class="float_ctrl"><em></em><span><a href="javascript:;" class="float_close" onclick="clearTimeout(nopermst);floatwinreset = 1;floatwin('close_fastpost');" title="关闭">关闭</a></span></h3>
<div class="float_message">您的请求来路不正确,无法提交。<script type="text/javascript" reload="1">
if(typeof messagehandle_fastpost =='function') {messagehandle_fastpost('0', '您的请求来路不正确,无法提交。');}
</script><br /><br />
<button onclick="floatwinreset = 1;floatwin('close_fastpost');">关闭</button>
</div>
</div>
]]></root>
void PostMessage(string text){
HttpWebRequest webRequest=WebRequest.Create("http://bbs.egou.com/post.php?action=reply&fid=19&tid=1222290&extra=page%3D1&replysubmit=yes&infloat=yes&handlekey=fastpost&inajax=1") as HttpWebRequest;
webRequest.Method="POST";
webRequest.Accept="image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/x-ms-xbap, application/x-ms-application, */*";
webRequest.Referer="http://bbs.egou.com/viewthread.php?tid=1222290&extra=page%3D1";
webRequest.UserAgent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; BTRS86335; .NET4.0C; TheWorld)Content-Type:application/x-www-form-urlencoded";
// webRequest.Connection="Keep-Alive";
webRequest.CookieContainer=webInof.cookieContainer;
string pst="formhash="+webInof.formhash+"&subject=&usesig=1&message=mark%21%21%21%21%21%21%21%21%21%21%21%21%21%21%21%21%21";
byte[] b=Encoding.ASCII.GetBytes(pst);
Stream requestStrem=webRequest.GetRequestStream();
requestStrem.Write(b,0,b.Length);
requestStrem.Close();
HttpWebResponse webResponse=webRequest.GetResponse() as HttpWebResponse;
Stream responseStream=webResponse.GetResponseStream();
StreamReader responseReader=new StreamReader(responseStream,Encoding.GetEncoding("gb2312"));
richTextBox1.Clear();
richTextBox1.AppendText(responseReader.ReadToEnd());
}
struct WebInfo{
public string formhash;
public CookieContainer cookieContainer;
}
WebInfo GetWebInfo(string url){
WebInfo webInfo=new MainForm.WebInfo();
HttpWebRequest webRequest=(HttpWebRequest)WebRequest.Create(url);
CookieContainer cookieC=new CookieContainer();
cookieC.GetCookies(webRequest.RequestUri);
webInfo.cookieContainer=cookieC;
HttpWebResponse webResponse=(HttpWebResponse)webRequest.GetResponse();
Stream responseStream=webResponse.GetResponseStream();
StreamReader responseReader=new StreamReader(responseStream,Encoding.GetEncoding("gb2312"));
string str=responseReader.ReadToEnd();
string formhash=str.Substring(str.IndexOf("formhash=")+9,8);
webInfo.formhash=formhash;
return webInfo;
}
void LoginBtnClick(object sender, EventArgs e)
{
WebInfo webInof;
webInof=GetWebInfo("http://bbs.egou.com/logging.php?action=login&infloat=yes&handlekey=login&inajax=1&ajaxtarget=floatwin_login");
Encoding coder=Encoding.GetEncoding("utf-8");
string str="formhash="+webInof.formhash+"&loginfield=username&username="+
userText.Text+"&password="+passText.Text+
"&questionid=0&answer=&loginsubmit=true";
byte[] postByte=coder.GetBytes(str);
HttpWebRequest hwq=(HttpWebRequest)WebRequest.Create("http://bbs.egou.com");
hwq.CookieContainer=webInof.cookieContainer;
hwq.Method="POST";
hwq.ContentType="keep-alive";
hwq.Accept="application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
hwq.UserAgent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.237 Safari/534.10";
hwq.Referer="http://bbs.egou.com/logging.php?action=login";
hwq.ContentLength=postByte.Length;
Stream postStream=hwq.GetRequestStream();
postStream.Write(postByte,0,postByte.Length);
postStream.Close();
HttpWebResponse wrp=(HttpWebResponse)hwq.GetResponse();
Stream receiveStream=wrp.GetResponseStream();
StreamReader reader=new StreamReader(receiveStream,Encoding.GetEncoding("gb2312"));
string s=string.Empty;
while(!reader.EndOfStream){
s+=reader.ReadLine();
Application.DoEvents();
}
richTextBox1.Clear();
richTextBox1.AppendText(s);
}