163博客采集王源代码

warning: 这篇文章距离上次修改已过530天,其中的内容可能已经有所变动。

软件已失效不再更新,仅供学习,文明上网,禁止任何违反法规的行为!

                                                  163博客采集王

  void getBlogUidProc()
        {
            try
            {
                string user = txtUser.Text.Trim();
                string psw = txtPsw.Text.Trim();
                if (user == "" || psw == "")
                {
                    MessageBox.Show("用户名或密码不能为空", "错误");
                    btnStart.Enabled = true;
                    btnStop.Enabled = false;
                    return;
                }
                lStatus.Text = "正在获取个人信息....";

                NextUid = "";
               // string user = txtUser.Text.Trim();
                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://blog.163.com/" + user + "/");
                myRequest.Method = "GET";
                myRequest.ContentType = "application/x-www-form-urlencoded";
                myRequest.Accept = "text/plain";
                myRequest.Referer = "http://blog.163.com/" + user + "/";
                myRequest.UserAgent = "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)";

                myRequest.ReadWriteTimeout = 5000;

                //myRequest.CookieContainer = new CookieContainer();
                //myRequest.CookieContainer.Add(new Uri(visitUrl), app.Coll2);
                myRequest.AllowAutoRedirect = true;
                HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
                while (myResponse.StatusCode.ToString() = "OK")
                {
                    Application.DoEvents();
                }
                StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.Default);
                string content = reader.ReadToEnd();
                reader.Close();
                int iStart = content.IndexOf("UD.host = { userId:", 1);
                int iEnd = content.IndexOf(",", iStart);
                string myUid = content.Substring(iStart + 19, iEnd - iStart - 19);
                NextUid = myUid;
                lStatus.Text = "获取个人信息成功";
            }
            catch
            {
                MessageBox.Show("获取个人信息失败", "错误");
                btnStart.Enabled = true;
                btnStop.Enabled = false;
            }
        }

软件已失效不再更新,仅供学习,文明上网,禁止任何违反法规的行为!

none
最后修改于:2023年06月14日 23:32

评论已关闭