Exemplo n.º 1
0
        public List <News> Getall(int star)
        {
            string      res    = MyRequest.createurl_news(null, null, null, star.ToString());
            List <News> mynews = new List <News>();

            mynews = MyRequest.analysis_news(res);
            return(mynews);
        }
        /// <summary>
        /// 按关键字和页数获得新闻
        /// </summary>
        /// <param name="keyword"></param>关键字
        /// <param name="star"></param>页数
        /// <returns></returns>
        public List <News> Getall(string keyword, int star)
        {
            string      res         = MyRequest.createurl_news(null, null, keyword, star.ToString());
            List <News> KeywordNews = new List <News>();

            KeywordNews = MyRequest.analysis_news(res);
            return(KeywordNews);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 以推荐类获得的用户喜欢的类型为参数,调用Myrequest获得该类型的新闻
        /// </summary>
        /// <returns></returns>
        public List <News> Getlike(string id)
        {
            List <News> mylike = new List <News>();
            Recommend   re     = new Recommend();

            re.getusertype(id);       //获得用户喜欢的新闻类型(从logdata表获得)
            re.GetUserSecondtype(id); //获得用户喜欢的类型(可能为多个,从users表获得)
            re.GetKeyword(id);        //获得用户经常搜索的关键字(从userkeyword表中获得)
            string usertype = re.getfirsttype();

            //类型不为空才推荐
            if (!string.IsNullOrEmpty(usertype))
            {
                string res = MyRequest.createurl_news(null, usertype, null, null);
                mylike = MyRequest.analysis_news(res);
            }
            //判断类型是否大于1个,包含逗号就大于1个
            if (re.getsecondtype().Contains(","))
            {
                //将每一个类型的新闻都添加到mylike中
                string[] usertypes = re.getsecondtype().Split(',');
                //将获得的类型都添加到mylike中
                foreach (string type in usertypes)
                {
                    string res = MyRequest.createurl_news(null, type, null, null);
                    mylike.AddRange(MyRequest.analysis_news(res));
                }
            }
            else
            {
                string usertype2 = re.getsecondtype();
                //类型不为空才推荐
                if (!string.IsNullOrEmpty(usertype2))
                {
                    string res = MyRequest.createurl_news(null, usertype2, null, null);
                    mylike.AddRange(MyRequest.analysis_news(res));
                }
            }
            string userkeyword = re.getkeyword();

            //关键字不为空才推荐
            if (userkeyword != null)
            {
                string res = MyRequest.createurl_news(null, null, userkeyword, null);
                mylike.AddRange(MyRequest.analysis_news(res));
            }
            return(mylike);
        }