Init WebScrap Demo

This commit is contained in:
Alexander Kozachenko 2023-11-06 19:29:11 +03:00
commit 7b0353341b
4 changed files with 68 additions and 0 deletions

View file

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DevOvercome.WebScrap" Version="1.0.0-rc.5" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo", "Demo.csproj", "{3735D643-CB62-446F-BCAD-C519785DF26C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3735D643-CB62-446F-BCAD-C519785DF26C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3735D643-CB62-446F-BCAD-C519785DF26C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3735D643-CB62-446F-BCAD-C519785DF26C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3735D643-CB62-446F-BCAD-C519785DF26C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AD5B549D-74E1-4C89-A4B6-505FCB0B0423}
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,21 @@
using DevOvercome.WebScrap;
var request = "https://en.wikipedia.org/wiki/Food_energy";
// Download the html:
using var client = new HttpClient();
using var response = await client.GetAsync(request);
var html = await response.Content.ReadAsStringAsync();
// Run the WebScrapper:
var css = "#firstHeading";
var result = new WebScrapper(html)
.Run(css)
.AsJson()
.ToJsonString();
// Get the results:
Console.WriteLine(result);
// OUTPUT:
// [{"key":"#firstHeading","values":[{"value":"Food energy"}]}]
Console.Read();

View file

@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}