Show / Hide Table of Contents

Installation

To get started, install the implementation package\s of choice

The following installation procedure is written for the Facebook package but is the same for other packages

  • dotnet CLI
  • Project file

Run the following:

dotnet add package Scraper.Net.Facebook

Add this to your project's .csproj file:

<PackageReference Include="Scraper.Net.Facebook" Version="*" />

Usage

var provider = new ServiceCollection()
    .AddLogging()
    .AddScraper(builder => builder.AddFacebook())
    .BuildServiceProvider();

var service = provider.GetRequiredService<IScraperService>();

var posts = service.GetPostsAsync("NaftaliBennett", "facebook");

await foreach (var post in posts)
{
    Console.WriteLine(post.Content);
}

In the following example Microsoft.Extensions.DependencyInjection is used to create an IScraperService.

Using the AddScraper extension method it is possible to register in the ScraperBuilder your desired platform scraper.

After building the service provider, the generated IScraperService is used to get the posts asynchronously using async enumerable and print their content.

  • Improve this Doc
In This Article
Back to top Generated by DocFX