예제 #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);
        }
예제 #2
0
        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();
        }
예제 #3
0
 public NormalProvdier(SourceConfig sourceConfig, DateTime lastUpdateDate)
 {
     this.sourceConfig   = sourceConfig;
     this.lastUpdateDate = lastUpdateDate;
 }
예제 #4
0
        public void load()
        {
            doc = new XmlDocument();
            doc.Load(DocFile);
            XmlElement root = doc.DocumentElement;

            auths.Clear();
            sources.Clear();

            Hashtable table = new Hashtable();

            foreach (XmlElement block in root.ChildNodes)
            {
                if (block.Name == "AuthInfo")
                {
                    foreach (XmlElement authInfo in block.ChildNodes)
                    {
                        table.Clear();
                        table.Add("Username", "");
                        table.Add("Password", "");
                        foreach (XmlElement element in authInfo.ChildNodes)
                        {
                            if (table.ContainsKey(element.Name))
                            {
                                table[element.Name] = element.InnerText;
                            }
                        }
                        AuthConfig authConfig = new AuthConfig(table["Username"].ToString(), table["Password"].ToString());
                        auths.Add(authConfig);
                    }
                }
                if (block.Name == "SourceInfo")
                {
                    foreach (XmlElement sourceInfo in block.ChildNodes)
                    {
                        table.Clear();
                        table.Add("SourceName", "");
                        table.Add("CatalogRegex", "");
                        table.Add("ContentRegex", "");
                        table.Add("PrefixURL", "");
                        table.Add("Encoding", "");
                        table.Add("IsUsing", "false");
                        table.Add("CatalogURL", new List <string>());
                        foreach (XmlElement element in sourceInfo.ChildNodes)
                        {
                            if (table.ContainsKey(element.Name))
                            {
                                if (element.Name.Equals("CatalogURL"))
                                {
                                    ((List <string>)table["CatalogURL"]).Add(element.InnerText);
                                }
                                else
                                {
                                    table[element.Name] = element.InnerText;
                                }
                            }
                        }
                        SourceConfig sourceConfig = new SourceConfig();
                        sourceConfig.source_name   = table["SourceName"].ToString();
                        sourceConfig.catalog_regex = table["CatalogRegex"].ToString();
                        sourceConfig.content_regex = table["ContentRegex"].ToString();
                        sourceConfig.prefix_url    = table["PrefixURL"].ToString();
                        sourceConfig.encoder       = table["Encoding"].ToString();
                        sourceConfig.isUsing       = bool.Parse(table["IsUsing"].ToString());
                        sourceConfig.catalog_url   = (List <string>)table["CatalogURL"];
                        sources.Add(sourceConfig);
                    }
                }
                if (block.Name.Equals("LastUpdateDate"))
                {
                    lastUpdateDate = DateTime.FromBinary(long.Parse(block.InnerText));
                }
            }
        }