C# 网页抓取器
using IronWebScraper;

public class Program
{
    private static void Main(string[] args)
    {
        var ScrapeJob = new BlogScraper();
        ScrapeJob.Start();
    }
}

public class BlogScraper : WebScraper
{
    public override void Init()
    {
        LoggingLevel = LogLevel.All;
        Request("https://www.zyte.com/blog/", Parse);
    }

    public override void Parse(Response response)
    {
        foreach (HtmlNode title_link in response.Css(".oxy-post-title"))
        {
            string strTitle = title_link.TextContentClean;
            Scrape(new ScrapedData() { { "Title", strTitle } });
        }

        if (response.CssExists("div.oxy-easy-posts-pages > a[href]"))
        {
            string next_page = response.Css("div.oxy-easy-posts-pages > a[href]")[0].Attributes["href"];
            Request(next_page, Parse);
        }
    }
}
NuGet Download
PM > Install-Package IronWebScraper
C# 网页抓取器

C# 网页抓取器

IronWebScraper 提供了一个强大的框架来使用 C# 代码从网站中提取数据和文件。

  1. 使用NuGet将 IronWebScraper 安装到您的项目中。
  2. 创建一个扩展WebScraper的类。
  3. 创建一个Request方法解析至少一个URL。
  4. 创建一个Request更多页面。 使用response.Css来使用jQuery风格的CSS选择器处理HTML元素。
  5. 在您的应用程序中,创建一个您自己的网页抓取类的实例并调用Start();方法。
  6. 阅读我们的C#网络抓取教程以学习如何使用IronWebScraper创建高级网络抓取器。
了解如何使用 C# 抓取在线电影网站数据
在 GitHub 上查看

准备开始了吗?

Nuget Downloads 149,116版本:2026.11刚刚发布