一個朋友寫的新浪灌水機一部

 //灌水開始了
None.gif

None.gif
using System;
None.gif
using System.IO;
None.gif
using System.Net; None.gifusing System.Collections.Specialized;
None.gif
using System.Text;
None.gif
None.gif
namespace sina1
ExpandedBlockStart.gif
{
ExpandedSubBlockStart.gif
///
InBlock.gif
/// Summary description for Class1.
ExpandedSubBlockEnd.gif
///

InBlock.gif class Class1
ExpandedSubBlockStart.gif
{
ExpandedSubBlockStart.gif 
///
InBlock.gif 
/// The main entry point for the application.
ExpandedSubBlockEnd.gif 
///

InBlock.gif  [STAThread]
InBlock.gif 
static void Main(string[] args)
ExpandedSubBlockStart.gif 
{
InBlock.gif  
//   test3();
InBlock.gif  
//   return;
InBlock.gif  
//
InBlock.gif  
//   test1();
InBlock.gif  
//   return;
InBlock.gif

InBlock.gif   WebClient clubIndexRequest
= new WebClient();
InBlock.gif   clubIndexRequest.Headers.Add(
"User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
InBlock.gif

InBlock.gif
5.1; .NET CLR 1.1.4322)");
InBlock.gif
   clubIndexRequest.Headers.Add("Accept", "*/*)");
InBlock.gif   Stream stream
= clubIndexRequest.OpenRead("http://house.sina.com.cn/allclub/index.html");
InBlock.gif   StreamReader reader
= new StreamReader(stream);
InBlock.gif   String clubIndexResponse
= reader.ReadToEnd();
InBlock.gif   String url
= "href=http://comment.sina.com.cn/cgi-bin/comment/comment.cgi";
InBlock.gif  
int pos1 = 0;
InBlock.gif  
int pos2 = 0;
InBlock.gif   String userName
= System.Web.HttpUtility.UrlEncode("抗議松下熱水器",
InBlock.gif
InBlock.gifEncoding.GetEncoding(
"GB2312"));
InBlock.gif  
string rawContent = "恐怖的鬆_下熱水器/r/n我本來不想買小_日本的東西的,但是老婆做主,買了
InBlock.gif

InBlock.gif一個鬆_下的燃氣熱水器,花了1千8百多大洋/r/n沒想到安裝的時候還收了我522元,522元啊!/r/n今天
InBlock.gif
InBlock.gif打投訴電話,居然說還有收8百多的!/r/n各位業主,買鬆_下熱水器的時候小心啊,說不定象我這樣當了
InBlock.gif
InBlock.gif冤大頭。/r/n我可以提供證據。
";
InBlock.gif
   String content = System.Web.HttpUtility.UrlEncode(rawContent, Encoding.GetEncoding
InBlock.gif
InBlock.gif(
"GB2312"));
InBlock.gif  
while((pos1 = clubIndexResponse.IndexOf(url, pos2)) >= 0)
ExpandedSubBlockStart.gif  
{
InBlock.gif   
// 分析業主論壇
InBlock.gif
    pos1 += url.Length + 1;
InBlock.gif    pos2
= clubIndexResponse.IndexOf(" ", pos1);
InBlock.gif    String clubStr
= clubIndexResponse.Substring(pos1, pos2 - pos1);
InBlock.gif   
// 預提交(新浪的防灌水措施)
InBlock.gif   
// 創建post數據
InBlock.gif
    String postStr = clubStr;
InBlock.gif    postStr
= postStr + "&top_title=";
InBlock.gif    postStr
= postStr + "&top_url=";
InBlock.gif    postStr
= postStr + "&user=" + userName;
InBlock.gif    postStr
= postStr + "&password=" + password;
InBlock.gif    postStr
= postStr + "&content=" + content;
InBlock.gif    postStr
= postStr + "&temp_content=" + content;
InBlock.gif   
byte [] postData = Encoding.ASCII.GetBytes(postStr);
InBlock.gif    WebClient command
= new WebClient();
InBlock.gif    command.Headers.Add(
"Content-Type", "application/x-www-form-urlencoded");
InBlock.gif    command.Headers.Add(
"User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
InBlock.gif

InBlock.gif.NET CLR
1.1.4322)");
InBlock.gif
    command.Headers.Add("Accept", "*/*)");
InBlock.gif   
try
ExpandedSubBlockStart.gif   
{
InBlock.gif    
byte [] returnData = command.UploadData("http://comment.sina.com.cn/cgi-
InBlock.gif

InBlock.gifbin
/comment/comment_do.cgi", "POST", postData);
InBlock.gif
     String cookie = command.ResponseHeaders["Set-Cookie"];
InBlock.gif     String returnStr
= Encoding.GetEncoding("GB2312").GetString(returnData);
InBlock.gif    
// 再分析,再提交(新浪的防灌水措施)
InBlock.gif
     String timeTagIndex = "", pos3);
InBlock.gif      String timeTag
= returnStr.Substring(pos3, pos4 - pos3);
InBlock.gif
InBlock.gif      String datetimeIndex
= "", pos3);
InBlock.gif       String dateTime
= returnStr.Substring(pos3, pos4 - pos3);
InBlock.gif       dateTime
= System.Web.HttpUtility.UrlEncode(dateTime, Encoding.GetEncoding
InBlock.gif
InBlock.gif(
"GB2312"));
InBlock.gif
InBlock.gif       String doCommentPostStr
= "hidecnt=1";
InBlock.gif       doCommentPostStr
= doCommentPostStr + "&" + clubStr;
InBlock.gif       doCommentPostStr
= doCommentPostStr + "&page=0";
InBlock.gif       doCommentPostStr
= doCommentPostStr + "&top_title=";
InBlock.gif       doCommentPostStr
= doCommentPostStr + "&top_url=";
InBlock.gif       doCommentPostStr
= doCommentPostStr + "&timetag=" + timeTag;
InBlock.gif       doCommentPostStr
= doCommentPostStr + "&datetime0=" + dateTime;
InBlock.gif       doCommentPostStr
= doCommentPostStr + "&uid0=" + userName;
InBlock.gif       doCommentPostStr
= doCommentPostStr + "&content0=" + content;
InBlock.gif       postData
= Encoding.ASCII.GetBytes(doCommentPostStr);
InBlock.gif       command.Headers.Add(
"Content-Type", "application/x-www-form-urlencoded");
InBlock.gif       command.Headers.Add(
"User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
InBlock.gif

InBlock.gif.NET CLR
1.1.4322)");
InBlock.gif
       command.Headers.Add("Accept", "*/*)");
InBlock.gif       command.Headers.Add(
"Referer", "http://comment.sina.com.cn/cgi-
InBlock.gif

InBlock.gifbin
/comment/comment_do.cgi");
InBlock.gif
       command.Headers.Add("Cookie", cookie);
InBlock.gif       returnData
= command.UploadData("http://comment.sina.com.cn/cgi-
InBlock.gif

InBlock.gifbin
/comment/comment.cgi", "POST", postData);
InBlock.gif
       returnStr = Encoding.GetEncoding("GB2312").GetString(returnData);
InBlock.gif       System.Console.WriteLine(
"/r/n***************發貼成功****************");
InBlock.gif       System.Console.WriteLine(clubStr);
InBlock.gif       System.Console.WriteLine(
"***************發貼成功****************");
ExpandedSubBlockEnd.gif      }
// if(pos3 >= 0)
ExpandedSubBlockEnd.gif
     }
// if(pos3 >= 0)
InBlock.gif
     else
ExpandedSubBlockStart.gif    
{
InBlock.gif      System.Console.WriteLine(
"/r/n***************接收到錯誤的信息****************");
InBlock.gif      System.Console.WriteLine(returnStr);
InBlock.gif      System.Console.WriteLine(
"***************接收到錯誤的信息****************");
ExpandedSubBlockEnd.gif     }

ExpandedSubBlockEnd.gif    }

InBlock.gif   
catch(Exception e)
ExpandedSubBlockStart.gif   
{
InBlock.gif     System.Console.WriteLine(
"/r/n***************發送異常****************");
InBlock.gif     System.Console.WriteLine(e.Message);
InBlock.gif     System.Console.WriteLine(
"***************發貼成功****************");
ExpandedSubBlockEnd.gif    }

InBlock.gif    System.Threading.Thread.Sleep(
10 * 1000);
ExpandedSubBlockEnd.gif   }

ExpandedBlockEnd.gif  }

None.gif }
None.gif}
None.gif
None.gif
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章