Ejemplo n.º 1
0
        /// <summary>
        /// 我的世界论坛新闻,成功返回true,失败返回false
        /// </summary>
        /// <param name="news">返回的数组</param>
        /// <returns></returns>
        public bool News(ref newsArray[] news)
        {
            if (url == "")
            {
                url = Web.getHtml("http://www.mcbbs.net/", true);
            }
            string ns;

            if (url != null)
            {
                ns = TakeTheMiddle(url, a, a1);
            }
            else
            {
                return(false);
            }
            string[]         s  = Regex.Split(ns, b);
            List <newsArray> ap = new List <newsArray>();

            for (int i = 0; s.Length > i; i++)
            {
                newsArray News = new newsArray();
                News.Url = TakeTheMiddle(s[i], c, c1);
                string ps = News.Url;
                if (ps.IndexOf('n') == -1)
                {
                    News.Url = "http://www.mcbbs.net" + News.Url;
                }
                News.Text = TakeTheMiddle(s[i], c1, d);
                News.IMG  = TakeTheMiddle(s[i], e, e1);
                ap.Add(News);
            }
            news = ap.ToArray();
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// mcbbs推荐新闻,成功返回true,失败返回false
        /// </summary>
        /// <param name="news">newArray数组</param>
        /// <returns></returns>
        public bool Recommend(ref newsArray[] news)
        {
            const string stra1 = "        <!--版主推荐-->";
            const string stra2 = "        <!--视频实况-->";
            const string strb1 = "           <a href=\"";
            const string strb2 = "\" class=\"";
            const string strc1 = "\"><img src=\"	";
            const string strc2 = "\" alt=\"";
            const string strd1 = "\" title=\"";

            if (url == "")
            {
                url = Web.getHtml("http://www.mcbbs.net/", true);
            }
            string ns;

            if (url != null)
            {
                ns = TakeTheMiddle(url, stra1, stra2);
            }
            else
            {
                return(false);
            }
            const string stra3 = "<div class=\"portal_li\">";
            const string stra4 = "\"/></a>";

            string[] str1 = new string[0];;
            ArrayTakeTheMiddle(ref str1, ns, stra3, stra4);
            List <newsArray> ap = new List <newsArray>();

            for (int i = 0; str1.Length > i; i++)
            {
                newsArray News = new newsArray();
                News.Url = TakeTheMiddle(str1[i], strb1, strb2);
                string ps = News.Url;
                if (ps.IndexOf('n') == -1)
                {
                    if (ps.IndexOf('/') == -1)
                    {
                        News.Url = "http://www.mcbbs.net/" + News.Url;
                    }
                    else
                    {
                        News.Url = "http://www.mcbbs.net" + News.Url;
                    }
                }
                News.IMG  = TakeTheMiddle(str1[i], strc1, strc2);
                News.Text = TakeTheMiddle(str1[i], strc2, strd1);
                ap.Add(News);
            }
            news = ap.ToArray();
            return(true);
        }