C# 网页抓取器
IronWebScraper 提供了一个强大的框架来使用 C# 代码从网站中提取数据和文件。
准备开始了吗?
Nuget 下载 128,072 | 版本: 2025.12 刚刚发布
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);
}
}
}Install-Package IronWebScraper
IronWebScraper 提供了一个强大的框架来使用 C# 代码从网站中提取数据和文件。