NScrape 1.0.0
dotnet add package NScrape --version 1.0.0
NuGet\Install-Package NScrape -Version 1.0.0
<PackageReference Include="NScrape" Version="1.0.0" />
<PackageVersion Include="NScrape" Version="1.0.0" />
<PackageReference Include="NScrape" />
paket add NScrape --version 1.0.0
#r "nuget: NScrape, 1.0.0"
#:package NScrape@1.0.0
#addin nuget:?package=NScrape&version=1.0.0
#tool nuget:?package=NScrape&version=1.0.0
NScrape
A web scraping framework for .NET that handles the plumbing — HTTP requests, cookies, redirects, form submission — so you can focus on extracting data.
Installation
dotnet add package NScrape
Quick Start
This example scrapes the book category list from books.toscrape.com.
1. Create a scraper
Inherit from Scraper and use the HTML Agility Pack HtmlDocument to extract data:
using NScrape;
public class BookstoreScraper : Scraper {
public BookstoreScraper( string html ) : base( html ) { }
public List<string> GetTitles() {
return HtmlDocument.DocumentNode
.Descendants( "article" )
.Where( n => n.Attributes["class"]?.Value == "product_pod" )
.Select( n => n.SelectSingleNode( ".//h3/a" ).Attributes["title"].Value )
.ToList();
}
}
2. Fetch the page and scrape it
using NScrape;
using NScrape.Interfaces;
var webClient = new WebClient();
using var response = webClient.SendRequest( new Uri( "https://books.toscrape.com" ) );
if ( response is IHtmlWebResponse htmlResponse ) {
var scraper = new BookstoreScraper( htmlResponse.Html );
var titles = scraper.GetTitles();
}
Features
- GET and POST requests
- Cookie management
- Automatic redirect handling
- HTML form submission (
BasicHtmlForm,BasicAspxForm) - Proxy support
- Extensible response handling via custom content type handlers
Proxy Support
NScrape supports routing requests through a proxy at either the client or per-request level:
// Client-level proxy — applies to all requests
webClient.Proxy = new WebProxy( "http://your-proxy:port" );
// Per-request proxy — overrides client proxy for this request
var request = new GetWebRequest( uri ) {
Proxy = new WebProxy( "http://your-proxy:port" )
};
For reliable scraping at scale, a dedicated proxy service such as ScrapingAnt (affiliate link) can help manage proxy rotation and avoid blocks.
Requirements
.NET 8.0 or later
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- HtmlAgilityPack (>= 1.12.4)
- Microsoft.Win32.SystemEvents (>= 10.0.8)
- Sprache.Signed (>= 2.3.1)
- System.Text.RegularExpressions (>= 4.3.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version 1.0.0 — Breaking changes release. See full release notes at
https://github.com/darrylwhitmore/NScrape/releases/tag/v1.0.0