练习

https://www.cnblogs.com/zhangxiaoyong/p/6043283.html

foreach (var x in Table.Data.XXX.Select(x => new { x.ID, x.Contents, x.ContentsHtml }).ToList())
            {


                string Contents = Regex.Replace(x.Contents, @"<p[^>]*>(?:\s| )*(.*?)</p>", "<p>$1</p>");
                string ContentsHtml = Regex.Replace(x.ContentsHtml, @"<p[^>]*>(?:\s| )*(.*?)</p>", "<p>$1</p>");
                Table.Data.<span style="font-family: Arial, Helvetica, sans-serif;">XXX</span><span style="font-family: Arial, Helvetica, sans-serif;">.Where(o => o.ID == x.ID).Update(new AJ.VO.Cms.ArtPO { Contents = Contents, ContentsHtml = ContentsHtml });</span>
            }


  string patten = @"http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?";
            Regex.Matches(GetHtml("http://www.diyigaokao.com/major/bklist.aspx"), patten, RegexOptions.IgnoreCase).Cast<Match>().ToList().ForEach(x =>
            {
                var info = new SpecialtyInstitutionPO { Caption = x.Groups[1].Value, SubjectType = eumSubjectType.Undergraduate };
                Table.Data.xxx.Insert(info);//专业
                Regex.Matches(x.Groups[2].Value, @"<h3>([^<]*)</h3>[\s\S]*?<ul\s+class=""cf"">([\s\S]*?)</ul>", RegexOptions.IgnoreCase).Cast<Match>().ToList().ForEach(y =>
                {
                    // Console.WriteLine("C2:" + y.Groups[1].Value);//子专业
                    Regex.Matches(y.Groups[2].Value, @"<a[\s\S]*?href=""([^""]*)""[\s\S]*?>([^<]*)</a>", RegexOptions.IgnoreCase).Cast<Match>().ToList().ForEach(z =>
                    {
                        SpecialtyPO special = new SpecialtyPO();
                        special.Caption = z.Groups[2].Value;
                        special.SpecialtyInstitutionID = info.ID;
                        special.DivisionType = eumDivisionType.LiberalArts;
                        special.Domain = GetChineseSpell(z.Groups[2].Value).ToLower();
                        //Console.WriteLine("Detail:" + z.Groups[2].Value + "  Link:" + z.Groups[1].Value);//子专业明细
                        Regex.Matches(GetHtml("http://www.diyigaokao.com" + z.Groups[1].Value), @"<li>([^<]*)<strong>专业代码:([^<]*)</strong>([^<]*)</li>", RegexOptions.IgnoreCase).Cast<Match>().ToList().ForEach(a =>
                         {
                             special.SpecialtyNo = a.Groups[3].Value;
                         });
                        Regex.Matches(GetHtml("http://www.diyigaokao.com" + z.Groups[1].Value), @"<div\s+class=""introduction""[^<>]*>[^<>]*<div\s+class=""ctn cf"">([\s\S]*?)</div>([^<]*)</div>", RegexOptions.IgnoreCase).Cast<Match>().ToList().ForEach(b =>
                        {
                            special.Contents = b.Groups[1].Value;
                        });
                        Table.Data.xxx.Insert(special);
                    });
                });
            });

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值