コード例 #1
0
 /// <summary>
 /// 获取用户信息
 /// </summary>
 public void GetUserInfo(object statues)
 {
     try
     {
         string id   = GetUserid();
         int    type = 0;
         //http://www.meilishuo.com/person/u/53558319
         string html = HttpHelper.GetHtml("http://www.meilishuo.com/person/u/" + id, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0", "application/json, text/javascript, */*; q=0.01", null, user.Cookie, null, Encoding.UTF8);
         HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
         doc.LoadHtml(html);
         //HtmlNode navnode = doc.DocumentNode.SelectSingleNode(@"//ul[@class='nav_list']");
         //HtmlNodeCollection nc = navnode.SelectNodes(@"//li/p/a");
         HtmlNode node    = doc.DocumentNode.SelectSingleNode(@"//a[@title='美丽说超级主编']");
         bool     issuper = false;
         if (node != null)
         {
             issuper = true;
             type    = 1;
         }
         node = doc.DocumentNode.SelectSingleNode(@"//span[@title='美丽说特别认证']");
         if (node != null)
         {
             issuper = true;
             type    = 2;
         }
         int liked = 0;
         node = doc.DocumentNode.SelectSingleNode(@"//span[@class='nums']");
         if (node != null)
         {
             liked = int.Parse(node.InnerText);
         }
         writelog("更新用户信息");
         client.BeginUpdateUserInfo(user.Username, liked, issuper, id, user.account, type, null, null);
     }
     catch (Exception ex)
     {
         string errorMsg = "An application error occurred. Please contact the adminstrator " +
                           "with the following information:/n/n";
         errorMsg += ex.Message + "/n/nStack Trace:/n" + ex.StackTrace + "//" + ex.Source;
         client.BeginLog(errorMsg, null, null);
     }
 }