Esempio n. 1
0
        public void TestCreateRule()
        {
            //RuleLiteDB.Remove(1);

            var rule = new RuleModel();

            rule.Url        = "http://www.ruijihg.com/2018/05/24/json-net-%e5%8f%8d%e5%ba%8f%e5%88%97%e5%8c%96%e6%8e%a5%e5%8f%a3%e9%9b%86%e5%90%88/";
            rule.Domain     = new Uri(rule.Url).GetDomain();
            rule.Expression = "http://www.ruijihg.com/????/??/??/*";

            var block = new ExtractBlock()
            {
                Selectors = new List <ISelector>
                {
                    new CssSelector("#main", CssTypeEnum.INNERHTML)
                },
                Metas = new ExtractMetaCollection()
            };

            block.Metas.AddMeta("time", new List <ISelector> {
                new CssSelector("time", CssTypeEnum.TEXT)
            });

            block.Metas.AddMeta("author", new List <ISelector> {
                new CssSelector(".author", CssTypeEnum.TEXT)
            });

            block.Metas.AddMeta("content", new List <ISelector> {
                new CssSelector(".entry-content", CssTypeEnum.INNERHTML)
            });

            rule.BlockExpression = JsonConvert.SerializeObject(block);

            //rule.Id = 1;
            RuleLiteDb.AddOrUpdate(rule);

            Assert.True(rule.Id > 0);
        }
 public void UpdateRule([FromBody] RuleModel rule)
 {
     RuleLiteDb.AddOrUpdate(rule);
 }
Esempio n. 3
0
 public void UpdateRule(RuleModel rule)
 {
     RuleLiteDb.AddOrUpdate(rule);
 }