zoukankan      html  css  js  c++  java
  • 步步为营-19-正则表达式的简单应用

    说明:现在我想查看博客园中,我都写了哪些随笔,都是什么时间写的.做一个数据的采集分析

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Threading.Tasks;
    
    namespace 博客园统计
    {
        class Program
        {
            static void Main(string[] args)
            {
                WebClient web = new WebClient();
                byte[] buffer = web.DownloadData(@"http://www.cnblogs.com/YK2012/");
                string html = Encoding.UTF8.GetString(buffer);
                MatchCollection mc = Regex.Matches(html, @"<a.+?homepage1.+?DayList.+?html.+?>(?<title>.+)</a>");
                MatchCollection name = Regex.Matches(html,@"@s(?<time>.+)逍遥小天狼");
                Console.WriteLine("一共有{0}篇文章",mc.Count);
                for (int i = 0; i < mc.Count; i++)
                {
                    if (mc.Count>0 && name.Count>0)
                    {
                        Console.WriteLine(mc[i].Groups["title"]);
                        Console.WriteLine(name[i].Groups["time"]);
                    }
                }
                Console.Read();
            }
        }
    }
    View Code

  • 相关阅读:
    Zabbix5 Frame 嵌套
    Zabbix5 对接 SAML 协议 SSO
    CentOS7 安装 Nexus
    CentOS7 安装 SonarQube
    GitLab 后台修改用户密码
    GitLab 查看版本号
    GitLab Admin Area 500 Error
    Linux 安装 PostgreSQL
    Liger ui grid 参数
    vue.js 是一个怪东西
  • 原文地址:https://www.cnblogs.com/YK2012/p/6722402.html
Copyright © 2011-2022 走看看