本文實例為大家分享了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(); } }}
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。
新聞熱點
疑難解答