Parsera.NET 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Parsera.NET --version 1.0.0                
NuGet\Install-Package Parsera.NET -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Parsera.NET" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Parsera.NET --version 1.0.0                
#r "nuget: Parsera.NET, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Parsera.NET as a Cake Addin
#addin nuget:?package=Parsera.NET&version=1.0.0

// Install Parsera.NET as a Cake Tool
#tool nuget:?package=Parsera.NET&version=1.0.0                

Parsera.NET

NuGet version (Parsera.NET)

GitHub License

Parsera.NET is a lightweight NuGet package for the Parsera API, designed to simplify interactions and streamline data scraping tasks. This wrapper offers an easy-to-use interface, enabling developers to harness the power of Parsera's capabilities effortlessly. Perfect for projects that require efficient web scraping with minimal overhead, this library ensures quick integration and optimal performance.

[!IMPORTANT] Parsera API key is required to use the package.

Installation

To use Parsera.NET in your C# project, you need to install the NuGet package. Follow these simple steps:

Using NuGet Package Manager

  1. Open Your Project: Open your project in Visual Studio or your preferred IDE.
  2. Open the Package Manager Console: Navigate to ToolsNuGet Package ManagerPackage Manager Console.
  3. Install Parsera.NET: Type the following command and press Enter: Install-Package Parsera.NET

Using .NET CLI

Alternatively, you can use .NET Core CLI to install Parsera.NET. Open your command prompt or terminal and run:

dotnet add package Parsera.NET

Verifying the Installation

After installation, make sure that Parsera.NET is listed in your project dependencies to confirm successful installation.

Usage

To get started with ParseraClient, create an instance of the ParseraClient class and use its methods to interact with the Parsera API. Below is an example of how you can retireve the list of available proxy countries:

var parseraClient = new ParseraClient("api-key");

var proxyCountries = await parseraClient.GetProxyCountriesAsync();

Console.WriteLine("Proxy countries:");
foreach (var country in proxyCountries.Take(10))
{
    Console.WriteLine($"{country.FriendlyName} ({country.SystemName})");
}

You can also extract data from a specific website, such as Hacker News:

var parseraClient = new ParseraClient("api-key");

var result = await parseraClient.ExtractAsync<ExtractionModel>("https://news.ycombinator.com/", "UnitedStates");

Console.WriteLine("\nExtraction result:");
var counter = 1;
foreach (var extraction in result)
{
    Console.WriteLine($"Extraction {counter++}");
    Console.WriteLine($"Title: {extraction.Title}");
    Console.WriteLine($"Points: {extraction.Points}");
    Console.WriteLine();
}

class ExtractionModel
{
    [Extraction("Title", "News title")]
    public string Title { get; set; }

    [Extraction("Points", "Number of points")]
    public int Points { get; set; }
}

Dependency Injection and Instancing

There are different ways to create an instance of ParseraClient in your project, either by instantiating it directly or using dependency injection (DI) in ASP.NET Core or other DI frameworks.

Instantiating Directly

You can create an instance of ParseraClient with an API key or options:

// With API key
var parseraClient = new ParseraClient("your-api-key");

// With custom options
var options = new ParseraClientOptions
{
    ApiKey = "your-api-key"
};
var parseraClient = new ParseraClient(options);
Using Dependency Injection (DI)

You can configure ParseraClient to be injected via the service container in DI-heavy environments like ASP.NET Core:

  1. With API Key
var builder = Host.CreateApplicationBuilder();

// Add ParseraClient to the service collection with API key
builder.Services.AddParseraClient("your-api-key");

var serviceProvider = builder.Build().Services;
var parseraClient = serviceProvider.GetRequiredService<IParseraClient>();
  1. With Custom Options
var builder = Host.CreateApplicationBuilder();

// Add ParseraClient to the service collection with custom options
builder.Services.AddParseraClient(new ParseraClientOptions
{
    ApiKey = _apiKey
});

var serviceProvider = builder.Build().Services;
var parseraClient = serviceProvider.GetRequiredService<IParseraClient>();

In both cases, you can retrieve an IParseraClient instance from the service provider and use it in your project.

Support the Project

If you find this project useful, consider supporting it by buying me a coffee. Your support is greatly appreciated!

Contributing

Contributions are welcome! If you have a feature to propose or a bug to fix, create a new pull request.

License

This project is licensed under the MIT License.

Acknowledgment

This project is inspired by and built upon the Parsera project.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 90 10/1/2024
1.0.0 90 9/23/2024