public IList<FeedEntity> GetList()
        {
            var list = new List<FeedEntity>();
                        
            for (int i = 1; i < 1000; i++)
            {
                web.URL = string.Format(url, i);
                string html = web.Get();
                var mats = reg_title.Matches(html);
                if (mats.Count == 0) break;
                foreach (Match mat in mats)
                {
                    var fd = new FeedEntity();
                    fd.Url = "http://blog.chinaunix.net" + mat.Groups[1].Value;
                    fd.Title = mat.Groups[2].Value;

                    if (fd.Title.StartsWith("[转载]"))
                    {
                        fd.Title = fd.Title.Substring(4);
                    }

                    list.Add(fd);
                }
            }
            return list;
        }
Exemple #2
0
        public IList<FeedEntity> GetList()
        {
            var list = new List<FeedEntity>();

            int p = 0;
            for (int i = 1; i < 1000; i++)
            {
                if (p > 0 && i > p) break;
                web.URL = string.Format(url, i);
                string html = web.Get();
                if (p == 0)
                {
                    var mp = Regex.Match(html, @"共(\d+)页");
                    if (mp.Success) p = App.ToInt(mp.Groups[1].Value);
                    else p = 1;
                }
                var mats = reg_title.Matches(html);
                if (mats.Count == 0) break;
                foreach (Match mat in mats)
                {
                    var fd = new FeedEntity();
                    fd.Url = "http://blog.csdn.com" + mat.Groups[1].Value;
                    fd.Title = mat.Groups[2].Value.Trim();

                    list.Add(fd);
                }
            }
            return list;
        }
Exemple #3
0
        public IList<FeedEntity> GetList()
        {
            var list = new List<FeedEntity>();

            int p = 0;
            for (int i = 1; i < 1000; i++)
            {
                if (p > 0 && i > p) break;

                web.URL = string.Format(url, i);
                string html = web.Get();
                if (p == 0)
                {
                    var mp = Regex.Match(html, @"<a href=""/\?page=(\d+)""[^>]*>[^<]+?</a> <a href=""/\?page=2"" class=""next_page""");
                    if (mp.Success) p = App.ToInt(mp.Groups[1].Value);
                    else p = 1;
                }
                var mats = reg_item.Matches(html);
                if (mats.Count == 0) break;
                foreach (Match mat in mats)
                {
                    Match m_t = reg_title.Match(mat.Value);
                    if (!m_t.Success) continue;

                    var fd = new FeedEntity();
                    fd.Url = url.Split('?')[0] + m_t.Groups[1].Value.TrimStart('/');
                    fd.Title = m_t.Groups[2].Value;
                    
                    list.Add(fd);
                }
                System.Threading.Thread.Sleep(1000);
            }
            return list;
        }
Exemple #4
0
        public IList <FeedEntity> GetList()
        {
            var list = new List <FeedEntity>();

            for (int i = 1; i < 1000; i++)
            {
                web.URL = string.Format(url, i);
                string html = web.Get();
                var    mats = reg_title.Matches(html);
                if (mats.Count == 0)
                {
                    break;
                }
                foreach (Match mat in mats)
                {
                    var fd = new FeedEntity();
                    fd.Url   = "http://blog.chinaunix.net" + mat.Groups[1].Value;
                    fd.Title = mat.Groups[2].Value;

                    if (fd.Title.StartsWith("[转载]"))
                    {
                        fd.Title = fd.Title.Substring(4);
                    }

                    list.Add(fd);
                }
            }
            return(list);
        }
Exemple #5
0
        public bool GetContent(ref FeedEntity entity)
        {
            if (entity.Content != string.Empty) return true;

            System.Threading.Thread.Sleep(2000);

            return service.GetContent(ref entity);
        }
Exemple #6
0
        public IList <FeedEntity> GetList()
        {
            var list = new List <FeedEntity>();

            int p = 0;

            for (int i = 1; i < 1000; i++)
            {
                if (p > 0 && i > p)
                {
                    break;
                }

                web.URL = string.Format(url, i);
                string html = web.Get();
                if (p == 0)
                {
                    var mp = Regex.Match(html, @"第(\d+)页");
                    if (mp.Success)
                    {
                        p = App.ToInt(mp.Groups[1].Value);
                    }
                    else
                    {
                        var mps = Regex.Matches(html, @">(\d+)</a><span class='pagesplit'>");
                        if (mps.Count > 0)
                        {
                            p = App.ToInt(mps[mps.Count - 1].Groups[1].Value);
                        }
                        else
                        {
                            p = 1;
                        }
                    }
                }

                var mats = reg_item.Matches(html);
                if (mats.Count == 0)
                {
                    break;
                }
                foreach (Match mat in mats)
                {
                    var m_t = reg_title.Match(mat.Value);
                    var fd  = new FeedEntity();
                    fd.Url   = m_t.Groups[1].Value;
                    fd.Title = m_t.Groups[2].Value;

                    if (fd.Title == "本文被设定为主人好友可见")
                    {
                        continue;
                    }

                    list.Add(fd);
                }
            }
            return(list);
        }
Exemple #7
0
        public bool GetContent(ref FeedEntity entity)
        {
            if (entity.Content != string.Empty)
            {
                return(true);
            }

            System.Threading.Thread.Sleep(2000);

            return(service.GetContent(ref entity));
        }
Exemple #8
0
 public bool GetContent(ref FeedEntity entity)
 {
     web.URL = entity.Url;
     string html = web.Get();
     Match mat = reg_con.Match(html);
     if (mat.Success)
     {
         entity.Content = mat.Groups[1].Value.Trim();
     }
     return mat.Success;
 }
Exemple #9
0
        public bool GetContent(ref FeedEntity entity)
        {
            web.URL = entity.Url;
            string html = web.Get();
            Match  mat  = reg_con.Match(html);

            if (mat.Success)
            {
                entity.Content = mat.Groups[1].Value.Trim();
            }
            return(mat.Success);
        }
Exemple #10
0
        public IList <FeedEntity> GetList()
        {
            var list = new List <FeedEntity>();

            int p = 0;

            for (int i = 1; i < 1000; i++)
            {
                if (p > 0 && i > p)
                {
                    break;
                }

                web.URL = string.Format(url, i);
                string html = web.Get();
                if (p == 0)
                {
                    var mp = Regex.Match(html, @"<a href=""/\?page=(\d+)""[^>]*>[^<]+?</a> <a href=""/\?page=2"" class=""next_page""");
                    if (mp.Success)
                    {
                        p = App.ToInt(mp.Groups[1].Value);
                    }
                    else
                    {
                        p = 1;
                    }
                }
                var mats = reg_item.Matches(html);
                if (mats.Count == 0)
                {
                    break;
                }
                foreach (Match mat in mats)
                {
                    Match m_t = reg_title.Match(mat.Value);
                    if (!m_t.Success)
                    {
                        continue;
                    }

                    var fd = new FeedEntity();
                    fd.Url   = url.Split('?')[0] + m_t.Groups[1].Value.TrimStart('/');
                    fd.Title = m_t.Groups[2].Value;

                    list.Add(fd);
                }
                System.Threading.Thread.Sleep(1000);
            }
            return(list);
        }
Exemple #11
0
        public IList <FeedEntity> GetList()
        {
            var list = new List <FeedEntity>();

            int p = 0;

            for (int i = 1; i < 1000; i++)
            {
                if (p > 0 && i > p)
                {
                    break;
                }

                web.URL = string.Format(url, i);
                string html = web.Get();
                if (p == 0)
                {
                    var mp = Regex.Match(html, @"共(\d+)页");
                    if (mp.Success)
                    {
                        p = App.ToInt(mp.Groups[1].Value);
                    }
                    else
                    {
                        p = 1;
                    }
                }

                var mats = reg_title.Matches(html);
                if (mats.Count == 0)
                {
                    break;
                }
                foreach (Match mat in mats)
                {
                    var fd = new FeedEntity();
                    fd.Url   = mat.Groups[1].Value;
                    fd.Title = mat.Groups[2].Value;

                    if (fd.Title.StartsWith("[转载]"))
                    {
                        fd.Title = fd.Title.Substring(4);
                    }

                    list.Add(fd);
                }
            }
            return(list);
        }
Exemple #12
0
        private string GetContent(FeedEntity entity)
        {
            if (!feedService.GetContent(ref entity))
            {
                return(string.Empty);
            }

            string html = entity.Content;

            html = reg_br.Replace(html, "\n");
            html = reg_html.Replace(html, string.Empty);
            html = App.ToHtmlDecoded(html).Replace("\r", string.Empty).Replace("\n", "\r\n");

            return(html);
        }
Exemple #13
0
        private Chapter GetChapter(FeedEntity entity)
        {
            Font ft = new Font(baseFT, 12);

            Chapter chp = new Chapter(new Paragraph(entity.Title, new Font(baseFT, 18))
            {
                Alignment = Element.ALIGN_CENTER
            }, chp_idx++);

            chp.Add(new Paragraph(" "));
            chp.Add(new Paragraph(" "));

            string text = GetContent(entity);

            foreach (string line in text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
            {
                try
                {
                    if (line == "[code_begin]")
                    {
                        ft = codeFT;
                    }
                    else if (line == "[code_end]")
                    {
                        ft = new Font(baseFT, 12);
                    }
                    else if (line.StartsWith("[img]"))
                    {
                        Image img = Image.GetInstance(line.Substring(5));
                        if (img.Width > 40)
                        {
                            if (img.Width > 560)
                            {
                                img.ScaleToFit(560, 560);
                            }
                            img.Alignment = Element.ALIGN_CENTER;
                            chp.Add(img);
                        }
                    }
                    else
                    {
                        chp.Add(new Paragraph(line, ft));
                    }
                }
                catch { }
            }
            return(chp);
        }
Exemple #14
0
        public IList<FeedEntity> GetList()
        {
            var list = new List<FeedEntity>();

            int p = 0;
            for (int i = 1; i < 1000; i++)
            {
                if (p > 0 && i > p) break;
                web.URL = string.Format(url, i);
                string html = web.Get();
                if (p == 0)
                {
                    var mp = Regex.Match(html, @"共(\d+)页");
                    if (mp.Success) p = App.ToInt(mp.Groups[1].Value);
                    else p = 1;
                }
                var mats = reg_title.Matches(html);
                if (mats.Count == 0) break;
                foreach (Match mat in mats)
                {
                    var fd = new FeedEntity();
                    fd.Url = mat.Groups[1].Value.Split('#')[0].Split('?')[0].ToLower();
                    fd.Title = mat.Groups[3].Value;
                    if (fd.Url.Split('/')[3] != url.Split('/')[3])
                    {
                        continue;
                    }
                    if (fd.Title.StartsWith("[转]"))
                    {
                        fd.Title = fd.Title.Substring(3);
                    }
                    bool has = false;
                    foreach (var fe in list)
                    {
                        if (fe.Url == fd.Url || fe.Title == fd.Title)
                        {
                            has = true;
                            break;
                        }
                    }
                    if (has) continue;

                    list.Add(fd);
                }
            }
            return list;
        }
Exemple #15
0
        public IList<FeedEntity> GetList()
        {
            var list = new List<FeedEntity>();
            
            int p = 0;
            for (int i = 1; i < 1000; i++)
            {
                if (p > 0 && i > p) break;

                web.URL = string.Format(url, i);
                string html = web.Get();
                if (p == 0)
                {
                    var mp = Regex.Match(html, @"第(\d+)页");
                    if (mp.Success) p = App.ToInt(mp.Groups[1].Value);
                    else
                    {
                        var mps = Regex.Matches(html, @">(\d+)</a><span class='pagesplit'>");
                        if (mps.Count > 0)
                        {
                            p = App.ToInt(mps[mps.Count - 1].Groups[1].Value);
                        }
                        else p = 1;
                    }
                }

                var mats = reg_item.Matches(html);
                if (mats.Count == 0) break;
                foreach (Match mat in mats)
                {
                    var m_t = reg_title.Match(mat.Value);
                    var fd = new FeedEntity();
                    fd.Url = m_t.Groups[1].Value;
                    fd.Title = m_t.Groups[2].Value;

                    if (fd.Title == "本文被设定为主人好友可见")
                    {
                        continue;
                    }

                    list.Add(fd);
                }
            }
            return list;
        }
Exemple #16
0
        public IList <FeedEntity> GetList()
        {
            var list = new List <FeedEntity>();

            web.URL         = url;
            web.Referer     = "http://api.blog.163.com/crossdomain.html?t=20100205";
            web.ContentType = "text/plain";
            web.TimeOut     = 300000;

            string html = web.Post(@"callCount=1
scriptSessionId=${scriptSessionId}187
c0-scriptName=BlogBeanNew
c0-methodName=getBlogs
c0-id=0
c0-param0=number:" + userId + @"
c0-param1=number:0
c0-param2=number:100
batchId=222222", true);

            var m_tit = reg_title.Matches(html);

            if (m_tit.Count == 0)
            {
                return(list);
            }

            var m_con = reg_con.Matches(html);

            for (int i = 0; i < m_tit.Count; i++)
            {
                var fd = new FeedEntity();
                try
                {
                    fd.Title   = App.UtoGB(m_tit[i].Groups[1].Value);
                    fd.Content = App.UtoGB(m_con[i].Groups[1].Value);
                }
                catch
                {
                    continue;
                }
                list.Add(fd);
            }

            return(list);
        }
Exemple #17
0
        private string GetContent(FeedEntity entity)
        {
            if (!feedService.GetContent(ref entity))
            {
                return(string.Empty);
            }

            string html = entity.Content;

            html = reg_code1.Replace(html, "\n[code_begin]\n");
            html = reg_code2.Replace(html, "\n[code_end]\n");
            html = reg_img.Replace(html, "\n[img]$1\n");
            html = reg_br.Replace(html, "\n");
            html = reg_html.Replace(html, string.Empty);
            html = App.ToHtmlDecoded(html);

            return(html);
        }
Exemple #18
0
        public FeedEntity GetEntity(string url)
        {
            var entity = new FeedEntity();

            web.URL = url;
            string html = web.Get();
            Match mat = reg_title.Match(html);
            if (mat.Success)
            {
                entity.Title = mat.Groups[2].Value.Trim();
            }
            mat = reg_con.Match(html);
            if (mat.Success)
            {
                entity.Content = mat.Groups[1].Value.Trim();
            }
            return entity;
        }
Exemple #19
0
        public IList <FeedEntity> GetList()
        {
            var list = new List <FeedEntity>();

            int p = 0;

            for (int i = 1; i < 1000; i++)
            {
                if (p > 0 && i > p)
                {
                    break;
                }

                web.URL = string.Format(url, i);
                string html = web.Get();
                if (p == 0)
                {
                    var mp = Regex.Match(html, @"页数 \( 1/(\d+) \)");
                    if (mp.Success)
                    {
                        p = App.ToInt(mp.Groups[1].Value);
                    }
                    else
                    {
                        p = 1;
                    }
                }

                var mats = reg_title.Matches(html);
                if (mats.Count == 0)
                {
                    break;
                }
                foreach (Match mat in mats)
                {
                    var fd = new FeedEntity();
                    fd.Url   = "http://" + url.Split('/')[2] + mat.Groups[2].Value;
                    fd.Title = mat.Groups[3].Value;

                    list.Add(fd);
                }
            }
            return(list);
        }
Exemple #20
0
        public FeedEntity GetEntity(string url)
        {
            var entity = new FeedEntity();

            web.URL = url;
            string html = web.Get();
            Match  mat  = reg_title2.Match(html);

            if (mat.Success)
            {
                entity.Title = reg_html.Replace(mat.Groups[1].Value, string.Empty).Trim();
            }
            mat = reg_con.Match(html);
            if (mat.Success)
            {
                entity.Content = mat.Groups[1].Value.Trim();
            }
            return(entity);
        }
Exemple #21
0
        public IList<FeedEntity> GetList()
        {
            var list = new List<FeedEntity>();
            
            web.URL = url;
            web.Referer = "http://api.blog.163.com/crossdomain.html?t=20100205";
            web.ContentType = "text/plain";
            web.TimeOut = 300000;

            string html = web.Post(@"callCount=1
scriptSessionId=${scriptSessionId}187
c0-scriptName=BlogBeanNew
c0-methodName=getBlogs
c0-id=0
c0-param0=number:" + userId + @"
c0-param1=number:0
c0-param2=number:100
batchId=222222", true);

            var m_tit = reg_title.Matches(html);
            if (m_tit.Count == 0) return list;

            var m_con = reg_con.Matches(html);

            for (int i = 0; i < m_tit.Count; i++)
            {
                var fd = new FeedEntity();
                try
                {
                    fd.Title = App.UtoGB(m_tit[i].Groups[1].Value);
                    fd.Content = App.UtoGB(m_con[i].Groups[1].Value);
                }
                catch
                {
                    continue;
                }
                list.Add(fd);
            }

            return list;
        }
Exemple #22
0
        public IList<FeedEntity> GetList()
        {
            var list = new List<FeedEntity>();
            
            for (int i = 1; i < 1000; i++)
            {
                web.URL = string.Format(url, i);
                string html = web.Get();
                var mats = reg_title.Matches(html);
                if (mats.Count == 0) break;
                foreach (Match mat in mats)
                {
                    var fd = new FeedEntity();
                    fd.Url = mat.Groups[1].Value;
                    fd.Title = mat.Groups[2].Value;

                    list.Add(fd);
                }
            }
            return list;
        }
Exemple #23
0
        public IList <FeedEntity> GetList()
        {
            var list = new List <FeedEntity>();

            for (int i = 1; i < 1000; i++)
            {
                web.URL = string.Format(url, i);
                string html = web.Get();
                var    mats = reg_title.Matches(html);
                if (mats.Count == 0)
                {
                    break;
                }
                foreach (Match mat in mats)
                {
                    var fd = new FeedEntity();
                    fd.Url   = mat.Groups[1].Value;
                    fd.Title = mat.Groups[2].Value;

                    list.Add(fd);
                }
            }
            return(list);
        }
Exemple #24
0
        private Chapter GetChapter(FeedEntity entity)
        {
            Font ft = new Font(baseFT, 12);

            Chapter chp = new Chapter(new Paragraph(entity.Title, new Font(baseFT, 18)) { Alignment = Element.ALIGN_CENTER }, chp_idx++);
            chp.Add(new Paragraph(" "));
            chp.Add(new Paragraph(" "));

            string text = GetContent(entity);
            foreach (string line in text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
            {
                try
                {
                    if (line == "[code_begin]")
                    {
                        ft = codeFT;
                    }
                    else if (line == "[code_end]")
                    {
                        ft = new Font(baseFT, 12);
                    }
                    else if (line.StartsWith("[img]"))
                    {
                        Image img = Image.GetInstance(line.Substring(5));
                        if (img.Width > 40)
                        {
                            if (img.Width > 560) img.ScaleToFit(560, 560);
                            img.Alignment = Element.ALIGN_CENTER;
                            chp.Add(img);
                        }
                    }
                    else
                    {
                        chp.Add(new Paragraph(line, ft));
                    }
                }
                catch { }
            }
            return chp;
        }
        public IList <FeedEntity> GetList()
        {
            var list = new List <FeedEntity>();

            int p = 0;

            for (int i = 1; i < 1000; i++)
            {
                if (p > 0 && i > p)
                {
                    break;
                }
                web.URL = string.Format(url, i);
                string html = web.Get();
                if (p == 0)
                {
                    var mp = Regex.Match(html, @"共(\d+)页");
                    if (mp.Success)
                    {
                        p = App.ToInt(mp.Groups[1].Value);
                    }
                    else
                    {
                        p = 1;
                    }
                }
                var mats = reg_title.Matches(html);
                if (mats.Count == 0)
                {
                    break;
                }
                foreach (Match mat in mats)
                {
                    var fd = new FeedEntity();
                    fd.Url   = mat.Groups[1].Value.Split('#')[0].Split('?')[0].ToLower();
                    fd.Title = mat.Groups[3].Value;
                    if (fd.Url.Split('/')[3] != url.Split('/')[3])
                    {
                        continue;
                    }
                    if (fd.Title.StartsWith("[转]"))
                    {
                        fd.Title = fd.Title.Substring(3);
                    }
                    bool has = false;
                    foreach (var fe in list)
                    {
                        if (fe.Url == fd.Url || fe.Title == fd.Title)
                        {
                            has = true;
                            break;
                        }
                    }
                    if (has)
                    {
                        continue;
                    }

                    list.Add(fd);
                }
            }
            return(list);
        }
Exemple #26
0
 public bool GetContent(ref FeedEntity entity)
 {
     return(true);
 }
Exemple #27
0
 public bool GetContent(ref FeedEntity entity)
 {
     return true;
 }
Exemple #28
0
        private Chapter GetChapter(FeedEntity entity)
        {
            Font ft = new Font(baseFT, 12);

            Chapter chp = new Chapter(new Paragraph(entity.Title, new Font(baseFT, 12)) { Alignment = Element.ALIGN_CENTER }, chp_idx++);
            chp.Add(new Paragraph(" "));
            chp.Add(new Paragraph(" "));

            string text = GetContent(entity);
            int rownum = 1;
            foreach (string line in text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
            {
                try
                {
                    if (line == "[code_begin]")
                    {
                        //ft = codeFT;
                        ft = new Font(codeFT, 11);
                    }
                    else if (line == "[code_end]")
                    {
                        ft = new Font(baseFT, 12);
                    }
                    else if (line.StartsWith("[img]"))
                    {
                        Image img = Image.GetInstance(line.Substring(5));
                        if (img.Width > 40)
                        {
                            if (img.Width > 560) img.ScaleToFit(560, 560);
                            img.Alignment = Element.ALIGN_CENTER;
                            chp.Add(img);
                        }
                    }
                    else if (line.Replace("\t","").StartsWith("//"))
                    {
                        iTextSharp.text.Font font = new iTextSharp.text.Font(codeFT,11, Font.NORMAL, BaseColor.BLUE);
                        String line_ = line.Replace("\t", "    ");
                        chp.Add(new Paragraph(line_, font));
                    }
                    else if (line.Replace("\t", "").StartsWith("/*") || line.Replace("\t", "").StartsWith("*") || line.Replace("\t", "").StartsWith("*/"))
                    {
                        iTextSharp.text.Font font = new iTextSharp.text.Font(codeFT, 11, Font.NORMAL, BaseColor.GREEN);
                        String line_ = line.Replace("\t", "    ");
                        chp.Add(new Paragraph(line_, font));
                    }
                    else
                    {
                        String line_ = line.Replace("\t", "    ");
                        chp.Add(new Paragraph(line_, ft));
                    }

                }
                catch { }
            }
            return chp;
        }
Exemple #29
0
        private string GetContent(FeedEntity entity)
        {
            if (!feedService.GetContent(ref entity))
            {
                return string.Empty;
            }

            string html = entity.Content;
            html = reg_br.Replace(html, "\n");
            html = reg_html.Replace(html, string.Empty);
            html = App.ToHtmlDecoded(html).Replace("\r", string.Empty).Replace("\n", "\r\n");

            return html;
        }
Exemple #30
0
        private string GetContent(FeedEntity entity)
        {
            if (!feedService.GetContent(ref entity))
            {
                return string.Empty;
            }

            string html = entity.Content;
            html = reg_code1.Replace(html, "\n[code_begin]\n");
            html = reg_code2.Replace(html, "\n[code_end]\n");
            html = reg_img.Replace(html, "\n[img]$1\n");
            html = reg_br.Replace(html, "\n");
            html = reg_html.Replace(html, string.Empty);
            html = App.ToHtmlDecoded(html);

            return html;
        }