下面的代碼是自動向cnblogs中的小組發帖.........注意小組ID,主題ID,小組類型
首先采用firebug分析到發帖時的post地址以及參數,其中在headers中包含了cookies,把cookies復制下來放到d:\cookie.txt中,以分號隔開(a=b;c=d;),這些cookie中包含有身份驗證信息
之後讀取文件d:\data.txt,每1024個字節為一帖自動發送
代碼
using System;
using System.Collections.Generic;
using System.Web;
using System.Xml;
using System.IO;
using System.Text;
using System.Collections;
using System.Net;
using System.Threading;
namespace Haier1
{
class Program
{
public static Hashtable getCookieMap()
{
string sPath = "d:\cookie.txt";
Hashtable maps = new Hashtable();
FileStream fs = new FileStream(sPath, FileMode.Open);
StreamReader rf = new StreamReader(fs, System.Text.Encoding.GetEncoding("gb2312"));
string hm = "";
try
{
do
{
hm = rf.ReadLine();
} while (!rf.EndOfStream);
Console.WriteLine(hm);
String[] s1 = hm.Split(;);
// Console.Write(s1.Length);
for (int i = 0; i < s1.Length; i++)
{
int pos = s1[i].IndexOf(=);