Ejemplo n.º 1
0
        /// <summary>
        /// 获取json中的用户信息
        /// </summary>
        /// <param name="json"></param>
        private void GetUserInformation(string json)
        {
            JObject obj    = JObject.Parse(json);
            JToken  tocken = obj.SelectToken("initialState.entities.users.['" + url_token + "']");

            RedisManage.PushUserInfo(tocken.ToString());
        }
Ejemplo n.º 2
0
        public void  Analyse()
        {
            try
            {
                if (GetHtml())
                {
                    Stopwatch watch = new Stopwatch();
                    watch.Start();

                    followerResult result = SerializeHelper.DeserializeToObject <followerResult>(JSONstring);
                    if (!result.paging.is_end)
                    {
                        RedisManage.AddNextUrl(result.paging.next);
                    }
                    foreach (var item in result.data)
                    {
                        RedisManage.AddUrltoken(item.url_token);
                    }
                    watch.Stop();
                    Console.WriteLine("解析json用了{0}毫秒", watch.ElapsedMilliseconds.ToString());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Ejemplo n.º 3
0
        //获取用户关注列表的url
        private void  GetUserFlowerandNext(string json)
        {
            string foollowed = "https://www.zhihu.com/api/v4/members/" + url_token + "/followers?include=data%5B*%5D.answer_count%2Carticles_count%2Cfollower_count%2Cis_followed%2Cis_following%2Cbadge%5B%3F(type%3Dbest_answerer)%5D.topics&offset=0&limit=20";
            string following = "https://www.zhihu.com/api/v4/members/" + url_token + "/followees?include=data%5B%2A%5D.answer_count%2Carticles_count%2Cfollower_count%2Cis_followed%2Cis_following%2Cbadge%5B%3F%28type%3Dbest_answerer%29%5D.topics&limit=20&offset=0";

            RedisManage.AddNextUrl(following);
            RedisManage.AddNextUrl(foollowed);
        }
Ejemplo n.º 4
0
        //获取json中的用户信息
        private void  GetUserInformation(string json)
        {
            JObject obj    = JObject.Parse(json);
            string  xpath  = "['" + url_token + "']";
            JToken  tocken = obj.SelectToken("['entities']").SelectToken("['users']").SelectToken(xpath);

            RedisManage.PushUserInfo(tocken.ToString());
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 将队列中的用户信息持久化
 /// </summary>
 public void SaveUser()
 {
     using (ZhihuEntity Entity = new ZhihuEntity())
     {
         string json = RedisManage.GetUserInfo();
         User   user = SerializeHelper.DeserializeToObject <User>(json);
         Entity.user.Add(user);
         try
         {
             Entity.SaveChanges();
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.ToString());
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 将关注用户的人的URL存放到nexturl中
        /// </summary>
        /// <param name="currentPageIndex"></param>
        private void GetUserFollowers()
        {
            string foollowed = CommonConstant.ZHMembersRoot + url_token + "/followers?include=data%5B*%5D.answer_count%2Carticles_count%2Cfollower_count%2Cis_followed%2Cis_following%2Cbadge%5B%3F(type%3Dbest_answerer)%5D.topics&offset=0&limit=20";

            RedisManage.AddNextUrl(foollowed);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 将用户关注的人的URL存放到nexturl中
        /// </summary>
        /// <param name="offset"></param>
        private void GetUserfollowing()
        {
            string following = CommonConstant.ZHMembersRoot + url_token + "/followees?include=data%5B%2A%5D.answer_count%2Carticles_count%2Cfollower_count%2Cis_followed%2Cis_following%2Cbadge%5B%3F%28type%3Dbest_answerer%29%5D.topics&limit=20&offset=0";

            RedisManage.AddNextUrl(following);
        }