Esempio n. 1
0
        public override CategoryInfo GiveCategoryInfo(string response)//获取漫画分类列表,一个键值对
        {
            var          dataBaseName = "task.db";
            CategoryInfo info         = new CategoryInfo();
            SqlOperate   operate      = new SqlOperate();

            operate.CreateOrOpenDataBase(dataBaseName);
            Dictionary <string, string> dict = new Dictionary <string, string>();

            if (operate.isHasTable("jingmingyanDir") == false)
            {
                operate.CreateDirTemp("jingmingyanDir");
                Regex           regex   = new Regex(@"<a\s*href='(?<href>/\w+-\w+/)'>(?<title>\w+)");
                MatchCollection collect = regex.Matches(response);

                foreach (Match m in collect)
                {
                    if (dict.ContainsKey(m.Groups["title"].Value) == false)
                    {
                        dict.Add(m.Groups["title"].Value, hostName + m.Groups["href"].Value);
                        operate.InserDirectoryLink("jingmingyanDir", m.Groups["title"].Value, hostName + m.Groups["href"].Value);
                    }
                }
            }
            else
            {
                dict = operate.GetDirectory("jingmingyanDir");
            }

            operate.CloseDataBase();
            info.ComicList = dict;
            return(info);
        }