Example #1
0
        public void initialize_source()
        {
            sources.Clear();

            SourceConfig sourceConfig = new SourceConfig();

            sourceConfig.source_name   = "国家自然科学基金委";
            sourceConfig.catalog_regex = @"href=""(?<url>[^""]+?)"" id=""[\S]+"" title=""(?<title>[^""]+?)"" target=""_blank"">[\S]+</a></span><span class=""fr"">(?<time>[^<]+?)</span>";
            sourceConfig.content_regex = @"<!--ContentStart-->(?<content>((.|\r|\n)*))<!--ContentEnd-->";
            sourceConfig.addCatalogURL("http://www.nsfc.gov.cn/publish/portal0/tab87/module467/page1.htm");
            sourceConfig.addCatalogURL("http://www.nsfc.gov.cn/publish/portal0/tab87/module467/page2.htm");
            sourceConfig.addCatalogURL("http://www.nsfc.gov.cn/publish/portal0/tab87/module467/page3.htm");
            sourceConfig.addCatalogURL("http://www.nsfc.gov.cn/publish/portal0/tab87/module467/page4.htm");
            sourceConfig.addCatalogURL("http://www.nsfc.gov.cn/publish/portal0/tab87/module467/page5.htm");
            sourceConfig.prefix_url = "http://www.nsfc.gov.cn";
            sourceConfig.encoder    = "utf-8";
            sources.Add(sourceConfig);
            //<td class="STYLE30"><a href="./201704/t20170401_132280.htm" target="_blank" class=STYLE30>关于报送完善财政科研项目资金管理等政策落实情况的通知</a>(2017-04-01)

            sourceConfig               = new SourceConfig();
            sourceConfig.source_name   = "国家科学技术部";
            sourceConfig.catalog_regex = @"href=""(?<url>[^""]+?)"" target=""_blank"" class=STYLE30>(?<title>[^<]+?)</a>\((?<time>[^\)]+?)\)";
            sourceConfig.content_regex = @"<meta name=""ContentStart""/>(?<content>((.|\r|\n)*))<meta name=""ContentEnd""/>";
            sourceConfig.addCatalogURL("http://www.most.gov.cn/tztg/index.htm");
            sourceConfig.addCatalogURL("http://www.most.gov.cn/tztg/index_1.htm");
            sourceConfig.addCatalogURL("http://www.most.gov.cn/tztg/index_2.htm");
            sourceConfig.addCatalogURL("http://www.most.gov.cn/tztg/index_3.htm");
            sourceConfig.addCatalogURL("http://www.most.gov.cn/tztg/index_4.htm");
            sourceConfig.prefix_url = "http://www.most.gov.cn/tztg/";
            sourceConfig.encoder    = "gb2312";
            sources.Add(sourceConfig);

            //<li><span class="neimk2time">2017-03-23</span><a href="http://www.lninfo.gov.cn/index.php?m=content&c=index&a=show&catid=19&id=88803"
            //target ="_blank" style="font-weight:bold;" >关于征求《可持续发展实验区创新驱动发展评价暂行办法》和评价指标体系意见的通知</a></li>
            sourceConfig               = new SourceConfig();
            sourceConfig.source_name   = "辽宁省科学技术厅";
            sourceConfig.catalog_regex = @"<li><span class=[^>]+>(?<time>[^<]+?)</span><a href=""(?<url>[^""]+?)"" [^>]+>(?<title>[^<]+?)</a></li>";
            sourceConfig.content_regex = @"<!--newsbody begin-->(?<content>((.|\r|\n)*))<!--newsbody end-->";
            sourceConfig.addCatalogURL("http://www.lninfo.gov.cn/index.php?m=content&c=index&a=lists&catid=19");
            sourceConfig.addCatalogURL("http://www.lninfo.gov.cn/index.php?m=content&c=index&a=lists&catid=19&page=2");
            sourceConfig.addCatalogURL("http://www.lninfo.gov.cn/index.php?m=content&c=index&a=lists&catid=19&page=3");
            sourceConfig.addCatalogURL("http://www.lninfo.gov.cn/index.php?m=content&c=index&a=lists&catid=19&page=4");
            sourceConfig.addCatalogURL("http://www.lninfo.gov.cn/index.php?m=content&c=index&a=lists&catid=19&page=5");
            sourceConfig.prefix_url = "";
            sourceConfig.encoder    = "gb2312";
            sources.Add(sourceConfig);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            SourceConfig sourceConfig = new SourceConfig();

            sourceConfig.source_name   = sourceName.Text;
            sourceConfig.catalog_regex = catalog_regex.Text;
            sourceConfig.content_regex = content_regex.Text;
            sourceConfig.prefix_url    = prefix_url.Text;
            sourceConfig.encoder       = encoding.Text;
            sourceConfig.isUsing       = isUsing.Checked;
            foreach (String url in listBox2.Items)
            {
                sourceConfig.addCatalogURL(url);
            }
            sources.Add(sourceConfig);
            configHub.setSourceConfig(sources);
            refresh_list();
        }