Exemplo n.º 1
0
 /// <summary>
 /// 添加单章节至数据库
 /// </summary>
 /// <param name="_tcl">数据</param>
 /// <returns></returns>
 public static bool _b_Insert_Chapter_List(tb_chapter_list _tcl)
 {
     try
     {
         Cls_MySQLHelper <tb_chapter_list> _msh = new Cls_MySQLHelper <tb_chapter_list>();
         MySqlContext context = _msh.DbContext();
         context.Insert(_tcl);
         _msh.Dispose_Db();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 2
0
        public List <tb_chapter_list> _b_Get_Chapter_List()
        {
            //判断链接是否存在
            if (_tfi_Main == null || _url_Homepage == "")
            {
                return(null);
            }

            List <tb_chapter_list> _ltcl_ret = new List <tb_chapter_list>();

            HtmlWeb _web_Main = new HtmlWeb();

            _web_Main.OverrideEncoding = Encoding.UTF8;
            try
            {
                HtmlAgilityPack.HtmlDocument _doc_Main = new HtmlAgilityPack.HtmlDocument();
                _doc_Main = _web_Main.Load(_url_Homepage);
                //判断是否有数据
                if (_doc_Main.Text == "")
                {
                    return(null);
                }

                //获取章节列表
                HtmlNodeCollection _hnc_Chapter_List = _doc_Main.DocumentNode.SelectNodes("//div[starts-with(@id,'list')]/dl/dd/a");
                if (_hnc_Chapter_List.Count == 0)
                {
                    return(null);
                }
                foreach (HtmlNode _hn in _hnc_Chapter_List)
                {
                    tb_chapter_list _tcl_one = new tb_chapter_list();
                    _tcl_one.col_fiction_id   = _tfi_Main.col_fiction_id;
                    _tcl_one.col_volume_id    = 0;
                    _tcl_one.col_chapter_name = _hn.InnerText;
                    _tcl_one.col_chapter_url  = _tfi_Main.col_url_homepage + _hn.Attributes["href"].Value;
                    _ltcl_ret.Add(_tcl_one);
                }
            }
            catch
            {
                return(null);
            }

            return(_ltcl_ret);
        }
Exemplo n.º 3
0
 int _i_Index = 0;//编号
 public Frm_Fiction_Chapter_Content(tb_chapter_list _tcl, int _index)
 {
     InitializeComponent();
     _tcl_Now = _tcl;
     _i_Index = _index;
 }
Exemplo n.º 4
0
        /// <summary>
        /// 获取小说信息,包括章节,封皮
        /// </summary>
        /// <param name="_tfi"></param>
        /// <returns></returns>
        public tb_fiction_detail_info _o_Get_Fiction_All_Info(tb_fiction_info _tfi)
        {
            if (_tfi == null)
            {
                return(null);
            }

            tb_fiction_detail_info _tfdi = new tb_fiction_detail_info();

            _tfdi._tfi_Fiction  = new tb_fiction_info();
            _tfdi._ltcl_Chapter = new List <tb_chapter_list>();


            HtmlWeb _web_Main = new HtmlWeb();

            _web_Main.OverrideEncoding = Encoding.UTF8;
            try
            {
                HtmlAgilityPack.HtmlDocument _doc_Main = new HtmlAgilityPack.HtmlDocument();
                _doc_Main = _web_Main.Load(_tfi.col_url_homepage);
                //判断是否有数据
                if (_doc_Main.Text == "")
                {
                    return(null);
                }

                //获取小说名
                _tfdi._tfi_Fiction.col_fiction_name = _tfi.col_fiction_name;
                //小说主页链接
                _tfdi._tfi_Fiction.col_url_homepage = _tfi.col_url_homepage;

                //获取小说信息
                HtmlNodeCollection _hnc_Info = _doc_Main.DocumentNode.SelectNodes("//div[starts-with(@id,'maininfo')]/div[starts-with(@id,'info')]");
                if (_hnc_Info.Count == 0)
                {
                    return(null);
                }

                //获取小说作者
                _tfdi._tfi_Fiction.col_fiction_author = _tfi.col_fiction_author;

                //获取最后更新时间
                _tfdi._tfi_Fiction.col_update_time = _tfi.col_update_time;

                //获取最后更新章节及链接
                _tfdi._tfi_Fiction.col_update_chapter     = _tfi.col_update_chapter;
                _tfdi._tfi_Fiction.col_update_chapter_url = _tfi.col_update_chapter_url;

                //获取小说简介
                HtmlNodeCollection _hnc_Intro = _doc_Main.DocumentNode.SelectNodes("//div[starts-with(@id,'maininfo')]/div[starts-with(@id,'intro')]");
                if (_hnc_Intro.Count > 0)
                {
                    _tfdi._tfi_Fiction.col_fiction_introduction = _hnc_Intro[0].InnerText.Trim();
                }

                //小说封皮链接
                HtmlNodeCollection _hnc_Poster_URL = _doc_Main.DocumentNode.SelectNodes("//div[starts-with(@id,'sidebar')]/div/img");
                if (_hnc_Poster_URL.Count > 0)
                {
                    _tfdi._tfi_Fiction.col_url_poster = "https://www.qu.la" + _hnc_Poster_URL[0].Attributes["src"].Value;
                }


                //设置来源
                _tfdi._tfi_Fiction.col_fiction_source = "笔趣阁";

                //获取点击量
                _tfdi._tfi_Fiction.col_click_count = _tfi.col_click_count;

                //获取状态
                _tfdi._tfi_Fiction.col_fiction_stata = _tfi.col_fiction_stata;

                //小说类型
                _tfdi._tfi_Fiction.col_fiction_type = _tfi.col_fiction_type;


                //获取章节列表
                HtmlNodeCollection _hnc_Chapter_List = _doc_Main.DocumentNode.SelectNodes("//div[starts-with(@id,'list')]/dl/dd/a");
                if (_hnc_Chapter_List.Count != 0)
                {
                    foreach (HtmlNode _hn in _hnc_Chapter_List)
                    {
                        tb_chapter_list _tcl_one = new tb_chapter_list();
                        _tcl_one.col_fiction_id   = _tfi.col_fiction_id;
                        _tcl_one.col_volume_id    = 0;
                        _tcl_one.col_chapter_name = _hn.InnerText;
                        _tcl_one.col_chapter_url  = _tfi.col_url_homepage + _hn.Attributes["href"].Value;
                        _tfdi._ltcl_Chapter.Add(_tcl_one);
                    }
                }

                //获取小说封皮
                //链接有误
                if (_tfdi._tfi_Fiction.col_url_poster != "")
                {
                    _tfdi._img_Poster = Image.FromStream(WebRequest.Create(_tfdi._tfi_Fiction.col_url_poster)
                                                         .GetResponse().GetResponseStream());
                }


                return(_tfdi);
            }
            catch {
                return(null);
            }
        }