这篇文章主要为大家分享了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();
}
}
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程学习网。
沃梦达教程
本文标题为:C#简单爬虫案例分享


猜你喜欢
- 在C# 8中如何使用默认接口方法详解 2023-03-29
- Unity Shader实现模糊效果 2023-04-27
- Oracle中for循环的使用方法 2023-07-04
- C# 使用Aspose.Cells 导出Excel的步骤及问题记录 2023-05-16
- 如何使用C# 捕获进程输出 2023-03-10
- user32.dll 函数说明小结 2022-12-26
- WPF使用DrawingContext实现绘制刻度条 2023-07-04
- Unity3D实现渐变颜色效果 2023-01-16
- c# 模拟线性回归的示例 2023-03-14
- .NET CORE DI 依赖注入 2023-09-27