From 7b0353341b0c8aa23c86b067f11cae7850d7ab50 Mon Sep 17 00:00:00 2001 From: Alexander Kozachenko <119358312+Alex-Kozachenko@users.noreply.github.com> Date: Mon, 6 Nov 2023 19:29:11 +0300 Subject: [PATCH] Init WebScrap Demo --- ProSol.WebScrap.Demo.CLI/Demo.csproj | 14 +++++++++++ ProSol.WebScrap.Demo.CLI/Demo.sln | 25 ++++++++++++++++++++ ProSol.WebScrap.Demo.CLI/Program.cs | 21 ++++++++++++++++ ProSol.WebScrap.Demo.CLI/demo.code-workspace | 8 +++++++ 4 files changed, 68 insertions(+) create mode 100644 ProSol.WebScrap.Demo.CLI/Demo.csproj create mode 100644 ProSol.WebScrap.Demo.CLI/Demo.sln create mode 100644 ProSol.WebScrap.Demo.CLI/Program.cs create mode 100644 ProSol.WebScrap.Demo.CLI/demo.code-workspace diff --git a/ProSol.WebScrap.Demo.CLI/Demo.csproj b/ProSol.WebScrap.Demo.CLI/Demo.csproj new file mode 100644 index 0000000..2a42a96 --- /dev/null +++ b/ProSol.WebScrap.Demo.CLI/Demo.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/ProSol.WebScrap.Demo.CLI/Demo.sln b/ProSol.WebScrap.Demo.CLI/Demo.sln new file mode 100644 index 0000000..1526cdd --- /dev/null +++ b/ProSol.WebScrap.Demo.CLI/Demo.sln @@ -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 diff --git a/ProSol.WebScrap.Demo.CLI/Program.cs b/ProSol.WebScrap.Demo.CLI/Program.cs new file mode 100644 index 0000000..2249e1d --- /dev/null +++ b/ProSol.WebScrap.Demo.CLI/Program.cs @@ -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(); \ No newline at end of file diff --git a/ProSol.WebScrap.Demo.CLI/demo.code-workspace b/ProSol.WebScrap.Demo.CLI/demo.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/ProSol.WebScrap.Demo.CLI/demo.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file