C#简单爬虫案例分享

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

C#简单爬虫案例分享

  2021-04-03 我要评论

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
 class Program
 {
  static void Main(string[] args)
  {

   WebClient wc = new WebClient();
   wc.Encoding = Encoding.UTF8;
   string html = wc.DownloadString("http://www.lagou.com/");

   MatchCollection matches = Regex.Matches(html, "<a.*jobs.*>(.*)</a>");
   foreach (Match item in matches)
   {
    Console.WriteLine(item.Groups[1].Value);
   }
   Console.WriteLine(matches.Count);
   Console.ReadKey(); 
  }
 }
}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

您可能感兴趣的文章:

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们