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
Run the following:
dotnet add package Scraper.Net.Facebook
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.