/// <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); } }
/// <summary> /// 手工添加一个用户到库内(使用用户微博主页地址) /// </summary> /// <param name="url">用户微博主页</param> /// <param name="source">用户来源</param> public static void AddNewAuthorWithUrl(string url, Enums.AuthorSource source) { string html = HTMLJobProcessor.GetHTMLViaRequest(url); Match match = userIDReg.Match(html); if (match.Groups[1].Success) { AddNewAuthorWithID(match.Groups[1].Value, source); } }