Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arnab-developer/arnabdeveloper.htmlcontent.core
Get HTML content
https://github.com/arnab-developer/arnabdeveloper.htmlcontent.core
csharp dotnet nuget
Last synced: 19 days ago
JSON representation
Get HTML content
- Host: GitHub
- URL: https://github.com/arnab-developer/arnabdeveloper.htmlcontent.core
- Owner: Arnab-Developer
- License: mit
- Created: 2021-05-30T15:26:48.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-13T04:06:15.000Z (over 2 years ago)
- Last Synced: 2024-11-16T09:30:50.372Z (3 months ago)
- Topics: csharp, dotnet, nuget
- Language: C#
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HTML content
This is a library which takes a collection of HTTP URLs and returns HTML responses of them. Internally
it used `System.Net.WebClient` to get the HTML response of the URLs.Install from [NuGet](https://www.nuget.org/packages/ArnabDeveloper.HtmlContent.Core).
```
dotnet add package ArnabDeveloper.HtmlContent.Core
```There are five methods to get the HTML responses.
- `GetContent()` get html contents synchronously
- `GetContentAsync()` get html contents asynchronously
- `GetContentAsyncStream()` get html contents asynchronously but start to return
contents as they are ready before all are complete
- `GetContentParallelAsync()` get html contents asynchronously in parallel
- `GetContentParallelForEachAsync()` get html contents asynchronously in parallel
using `Parallel.ForEach()`
- `GetContentParallelForEachProgressAsync()` get html contents asynchronously in
parallel using `Parallel.ForEach()` and start to return contents as they are ready
before all are complete with progress data.Example code to use the library:
```csharp
IHtmlContentService _htmlContentService = new HtmlContentService();_htmlContentService.Urls.Add("http://google.com");
_htmlContentService.Urls.Add("http://microsoft.com");IEnumerable webSiteDataModels = _htmlContentService.GetContent();
foreach (WebSiteDataModel webSiteDataModel in webSiteDataModels)
{
Console.WriteLine(webSiteDataModel.WebsiteUrl);
Console.WriteLine(webSiteDataModel.WebsiteData);
}
```This is influenced by
[C# Advanced Async by TimCorey](https://www.youtube.com/watch?v=ZTKGRJy5P2M)