Exemplo n.º 1
0
        /// <summary>
        /// 手工添加一个用户到库内(使用用户ID)
        /// </summary>
        /// <param name="AuthorID">用户ID</param>
        /// <param name="source">用户来源</param>
        public static void AddNewAuthorWithID(string AuthorID, Enums.AuthorSource source)
        {
            var user   = WeiboAPI.GetAuthorInfo(AuthorID);
            var author = AuthorDBManager.ConvertToAuthor(user, source);

            AuthorDBManager.InsertOrUpdateAuthorInfo(author);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 刷新新浪微博名人排行榜,并更新数据库,即A1
 /// </summary>
 /// <returns>是否刷新成功</returns>
 public static bool UpdateCelebrityList()
 {
     try
     {
         int cnt = 0;
         for (int i = 1; i <= DefaultSettings.CelebrityPageCnt; ++i)
         {
             string url  = string.Format(urlPattern, i);
             string html = HTMLJobProcessor.GetHTMLViaRequest(url);
             Console.WriteLine("one web page fetched");
             MatchCollection matches = idreg.Matches(html);
             foreach (Match match in matches)
             {
                 string AuthorID = match.Groups[1].Value;
                 var    user     = WeiboAPI.GetAuthorInfo(AuthorID);
                 Console.WriteLine("got one user");
                 var author = AuthorDBManager.ConvertToAuthor(user, Palas.Common.Data.Enums.AuthorSource.ListedTop);
                 Console.WriteLine("converted to Author class");
                 Console.WriteLine("inserting...");
                 AuthorDBManager.InsertOrUpdateAuthorInfo(author);
                 Console.WriteLine("insert successfully");
                 Console.WriteLine(++cnt);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         Logger.Error(ex.ToString());
         return(false);
     }
 }