C#简单爬虫案例

2021-05-07 12:29

阅读:677

标签:.text   key   http   pre   client   blog   str   encoding   count   

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, "(.*)");
            foreach (Match item in matches)
            {
                Console.WriteLine(item.Groups[1].Value);
            }
            Console.WriteLine(matches.Count);
            Console.ReadKey();   
        }
    }
}

 

C#简单爬虫案例

标签:.text   key   http   pre   client   blog   str   encoding   count   

原文地址:http://www.cnblogs.com/xiaz/p/7644238.html


评论


亲,登录后才可以留言!