软件编程
位置:首页>> 软件编程>> C#编程>> C#简单爬虫案例分享

C#简单爬虫案例分享

作者:Mask-male  发布时间:2023-04-14 08:44:13 

标签:C#,爬虫

本文实例为大家分享了C#简单爬虫案例,供大家参考,具体内容如下


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();
 }
}
}

来源:http://www.cnblogs.com/xiaz/archive/2017/10/10/7644238.html

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com