日期:2014-05-17 浏览次数:20544 次
private void button1_Click(object sender, EventArgs e)
{
string url = "http://xc.netease.com/logging.php?action=login";
string path = Environment.CurrentDirectory + @"\list.txt";
string[] list = System.IO.File.ReadAllText(path).Split('\r');
Application.DoEvents();
for (int i = 0; i < list.Length; i++)
{
string[] arr = list[i].Split('-');
this.richTextBox1.Text += String.Format("{0}-{1} {2}", arr[0].Trim(), arr[1].Trim(), loginpage(url, arr[0], arr[1])) + Environment.NewLine;
this.Refresh(1);
}
this.richTextBox1.Text += "完成" + Environment.NewLine;
}
public string loginpage(string url, string uid, string password)
{
try
{
WebClient wc = new WebClient();
wc.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0");
string downhtml = System.Text.Encoding.GetEncoding("gb2312").GetString(wc.DownloadData(url));
string formhash = System.Text.RegularExpressions.Regex.Replace(downhtml, "[\\s*\\S*]*<input type=\"hidden\" name=\"formhash\" value=\"([^\"]*)\"[\\s*\\S*]*", "$1", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
string poststring = String.Format("formhash={0}&referer=index.php&loginfield=uid&username={1}&password={2}&questionid=0&answer=&cookietime=2592000&loginmode=&styleid=&loginsubmit=%CC%E1%BD%BB", formhash, uid, password);
wc = new WebClient();
wc.Headers.Add("Accept-Language", "zh-cn");