diff --git a/DrApi.cs b/DrApi.cs index f3de0cc..77d6fd1 100644 --- a/DrApi.cs +++ b/DrApi.cs @@ -1,24 +1,45 @@ using HtmlAgilityPack; using System; using System.Linq; +using AngleSharp; -class DrApi { +class DrApi +{ - public static async Task get_rants (string url) { + public static async Task> DomQueryClass(string htmlContent, string className) + { + var config = Configuration.Default; + var context = BrowsingContext.New(config); + var document = await context.OpenAsync(req => req.Content(htmlContent)); + + var elements = document.QuerySelectorAll($".{className}"); - string response = await HTTP.get(url).ConfigureAwait(false);; + return elements.Select(el => el.TextContent).ToList(); //OuterHtml).ToList() + } + + + public static async Task get_rants(string url) + { + + string response = await HTTP.get(url).ConfigureAwait(false); ; HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(response); - var nodes = doc.DocumentNode.SelectNodes("//a"); + + var nodes = await DomQueryClass(response, "rantlist-title-text"); + foreach (var node in nodes) + { + Console.WriteLine(node); + } + //var nodes = doc.DocumentNode.SelectNodes("//a"); //var nodes = doc.DocumentNode.SelectNodes("//a[contains(@class,'rantlist-content-col')"); //var nodes = doc.DocumentNode.SelectNodes("//div[contains(@class, 'rant-comment-row-widget')]"); - foreach (var node in nodes) { - Console.WriteLine(node.GetAttributeValue("class","None")); - if(node.GetAttributeValue("class","None") == "rantlist-bglink"){ + //foreach (var node in nodes) { + // Console.WriteLine(node.GetAttributeValue("class","None")); + // if(node.GetAttributeValue("class","None") == "rantlist-bglink"){ - Console.WriteLine(node.InnerText); - } - } + // Console.WriteLine(node.InnerText); + //} + //} return null; } diff --git a/Program.cs b/Program.cs index c95776f..39aa800 100644 --- a/Program.cs +++ b/Program.cs @@ -6,8 +6,17 @@ using System; using System.Net.Http; using System.Threading.Tasks; +using System; +using System.Runtime.InteropServices; + +namespace drnetapi { partial class Program { + public static string transform(string tr){ + return tr + tr; + } + + static async Task Main(string[] args){ Application.Init(); @@ -15,21 +24,29 @@ partial class Program { window.SetDefaultSize(320,240); window.DeleteEvent += (o,e) => Application.Quit(); - RunIt(); + var bgtask = RunIt(); window.ShowAll(); + + Application.Run(); + await bgtask; } static async Task RunIt() { + for(int i = 0; i < 100; i++){ + //Thread.Sleep(1000); string result = await DrApi.get_rants("https://devrant.com/feed/recent").ConfigureAwait(false); Console.WriteLine(result); + } } -} +}; + +}; diff --git a/bin/Debug/net8.0/drnetapi.deps.json b/bin/Debug/net8.0/drnetapi.deps.json index 6550663..cf6181d 100644 --- a/bin/Debug/net8.0/drnetapi.deps.json +++ b/bin/Debug/net8.0/drnetapi.deps.json @@ -8,6 +8,7 @@ ".NETCoreApp,Version=v8.0": { "drnetapi/1.0.0": { "dependencies": { + "AngleSharp": "1.1.2", "GtkSharp": "3.24.24.95", "HtmlAgilityPack": "1.11.71" }, @@ -15,6 +16,17 @@ "drnetapi.dll": {} } }, + "AngleSharp/1.1.2": { + "dependencies": { + "System.Text.Encoding.CodePages": "8.0.0" + }, + "runtime": { + "lib/net8.0/AngleSharp.dll": { + "assemblyVersion": "1.1.2.0", + "fileVersion": "1.1.2.0" + } + } + }, "AtkSharp/3.24.24.95": { "dependencies": { "GLibSharp": "3.24.24.95" @@ -102,7 +114,8 @@ "fileVersion": "3.24.24.95" } } - } + }, + "System.Text.Encoding.CodePages/8.0.0": {} } }, "libraries": { @@ -111,6 +124,13 @@ "serviceable": false, "sha512": "" }, + "AngleSharp/1.1.2": { + "type": "package", + "serviceable": true, + "sha512": "sha512-aRFpAqixbuj1Vmqy2hsWPF0PJygo1SfjvmpBvVWZv6i+/u+C/L4wDdwFIzyCGUbjqr61NsZdPNPqDE8wlmG2qA==", + "path": "anglesharp/1.1.2", + "hashPath": "anglesharp.1.1.2.nupkg.sha512" + }, "AtkSharp/3.24.24.95": { "type": "package", "serviceable": true, @@ -166,6 +186,13 @@ "sha512": "sha512-H7JeyEvLsgvsbamGpRgoNtdvzPiGwwsUuoeTobN1C/JRjw1J8Snw0yf2WBr7CKx5GLwbrwpQYOb7N/HD17ME8A==", "path": "pangosharp/3.24.24.95", "hashPath": "pangosharp.3.24.24.95.nupkg.sha512" + }, + "System.Text.Encoding.CodePages/8.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-OZIsVplFGaVY90G2SbpgU7EnCoOO5pw1t4ic21dBF3/1omrJFpAGoNAVpPyMVOC90/hvgkGG3VFqR13YgZMQfg==", + "path": "system.text.encoding.codepages/8.0.0", + "hashPath": "system.text.encoding.codepages.8.0.0.nupkg.sha512" } } } \ No newline at end of file diff --git a/bin/Debug/net8.0/drnetapi.dll b/bin/Debug/net8.0/drnetapi.dll index d71baf9..eabc776 100644 Binary files a/bin/Debug/net8.0/drnetapi.dll and b/bin/Debug/net8.0/drnetapi.dll differ diff --git a/bin/Debug/net8.0/drnetapi.pdb b/bin/Debug/net8.0/drnetapi.pdb index d36d2bf..0002d05 100644 Binary files a/bin/Debug/net8.0/drnetapi.pdb and b/bin/Debug/net8.0/drnetapi.pdb differ diff --git a/drnetapi.csproj b/drnetapi.csproj index 2a492ac..d71f0f0 100644 --- a/drnetapi.csproj +++ b/drnetapi.csproj @@ -8,6 +8,7 @@ + diff --git a/obj/Debug/net8.0/drnetapi.AssemblyInfo.cs b/obj/Debug/net8.0/drnetapi.AssemblyInfo.cs index 6631f5d..520fb6a 100644 --- a/obj/Debug/net8.0/drnetapi.AssemblyInfo.cs +++ b/obj/Debug/net8.0/drnetapi.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("drnetapi")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9e0e316cd3b7bd2058c7ce9b967b5ac68422bf36")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7fb519f419449f9dc0b2470d5e22b37ba71c9969")] [assembly: System.Reflection.AssemblyProductAttribute("drnetapi")] [assembly: System.Reflection.AssemblyTitleAttribute("drnetapi")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/obj/Debug/net8.0/drnetapi.AssemblyInfoInputs.cache b/obj/Debug/net8.0/drnetapi.AssemblyInfoInputs.cache index 8a69f3c..63da913 100644 --- a/obj/Debug/net8.0/drnetapi.AssemblyInfoInputs.cache +++ b/obj/Debug/net8.0/drnetapi.AssemblyInfoInputs.cache @@ -1 +1 @@ -f0a018514b0ac9989cefd4e8304d6c22b9ba22f2036bcbdc20cd35b98e0929b3 +885952bf447ff1bea5505c35b1c8231624b933a12c032ef1d33f249f3074a7e0 diff --git a/obj/Debug/net8.0/drnetapi.assets.cache b/obj/Debug/net8.0/drnetapi.assets.cache index 304c491..298d9be 100644 Binary files a/obj/Debug/net8.0/drnetapi.assets.cache and b/obj/Debug/net8.0/drnetapi.assets.cache differ diff --git a/obj/Debug/net8.0/drnetapi.csproj.AssemblyReference.cache b/obj/Debug/net8.0/drnetapi.csproj.AssemblyReference.cache index f9eb423..eb3c902 100644 Binary files a/obj/Debug/net8.0/drnetapi.csproj.AssemblyReference.cache and b/obj/Debug/net8.0/drnetapi.csproj.AssemblyReference.cache differ diff --git a/obj/Debug/net8.0/drnetapi.csproj.CoreCompileInputs.cache b/obj/Debug/net8.0/drnetapi.csproj.CoreCompileInputs.cache index 3054838..73d90c7 100644 --- a/obj/Debug/net8.0/drnetapi.csproj.CoreCompileInputs.cache +++ b/obj/Debug/net8.0/drnetapi.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -5e3e99658f7cc8eb082cd7c6cd551b3ff500dd816707657a9c3f556f838b6d19 +cb53997bd4f956d6fe419ccaf3b77c877689b448a89934fef62624a0029ccea3 diff --git a/obj/Debug/net8.0/drnetapi.csproj.FileListAbsolute.txt b/obj/Debug/net8.0/drnetapi.csproj.FileListAbsolute.txt index 39e20e8..f613648 100644 --- a/obj/Debug/net8.0/drnetapi.csproj.FileListAbsolute.txt +++ b/obj/Debug/net8.0/drnetapi.csproj.FileListAbsolute.txt @@ -46,3 +46,4 @@ /home/retoor/projects/drnetapi/obj/Debug/net8.0/drnetapi.pdb /home/retoor/projects/drnetapi/obj/Debug/net8.0/drnetapi.genruntimeconfig.cache /home/retoor/projects/drnetapi/obj/Debug/net8.0/ref/drnetapi.dll +/home/retoor/projects/drnetapi/bin/Debug/net8.0/AngleSharp.dll diff --git a/obj/Debug/net8.0/drnetapi.dll b/obj/Debug/net8.0/drnetapi.dll index d71baf9..eabc776 100644 Binary files a/obj/Debug/net8.0/drnetapi.dll and b/obj/Debug/net8.0/drnetapi.dll differ diff --git a/obj/Debug/net8.0/drnetapi.pdb b/obj/Debug/net8.0/drnetapi.pdb index d36d2bf..0002d05 100644 Binary files a/obj/Debug/net8.0/drnetapi.pdb and b/obj/Debug/net8.0/drnetapi.pdb differ diff --git a/obj/Debug/net8.0/ref/drnetapi.dll b/obj/Debug/net8.0/ref/drnetapi.dll index 60960ca..8d9a333 100644 Binary files a/obj/Debug/net8.0/ref/drnetapi.dll and b/obj/Debug/net8.0/ref/drnetapi.dll differ diff --git a/obj/Debug/net8.0/refint/drnetapi.dll b/obj/Debug/net8.0/refint/drnetapi.dll index 60960ca..8d9a333 100644 Binary files a/obj/Debug/net8.0/refint/drnetapi.dll and b/obj/Debug/net8.0/refint/drnetapi.dll differ diff --git a/obj/drnetapi.csproj.nuget.dgspec.json b/obj/drnetapi.csproj.nuget.dgspec.json index da27abe..e81fc00 100644 --- a/obj/drnetapi.csproj.nuget.dgspec.json +++ b/obj/drnetapi.csproj.nuget.dgspec.json @@ -38,6 +38,10 @@ "net8.0": { "targetAlias": "net8.0", "dependencies": { + "AngleSharp": { + "target": "Package", + "version": "[1.1.2, )" + }, "GtkSharp": { "target": "Package", "version": "[3.24.24.95, )" diff --git a/obj/project.assets.json b/obj/project.assets.json index 1b89090..b07a09c 100644 --- a/obj/project.assets.json +++ b/obj/project.assets.json @@ -2,6 +2,22 @@ "version": 3, "targets": { "net8.0": { + "AngleSharp/1.1.2": { + "type": "package", + "dependencies": { + "System.Text.Encoding.CodePages": "8.0.0" + }, + "compile": { + "lib/net8.0/AngleSharp.dll": { + "related": ".xml" + } + }, + "runtime": { + "lib/net8.0/AngleSharp.dll": { + "related": ".xml" + } + } + }, "AtkSharp/3.24.24.95": { "type": "package", "dependencies": { @@ -104,10 +120,57 @@ "runtime": { "lib/net6.0/PangoSharp.dll": {} } + }, + "System.Text.Encoding.CodePages/8.0.0": { + "type": "package", + "compile": { + "lib/net8.0/System.Text.Encoding.CodePages.dll": { + "related": ".xml" + } + }, + "runtime": { + "lib/net8.0/System.Text.Encoding.CodePages.dll": { + "related": ".xml" + } + }, + "build": { + "buildTransitive/net6.0/_._": {} + }, + "runtimeTargets": { + "runtimes/win/lib/net8.0/System.Text.Encoding.CodePages.dll": { + "assetType": "runtime", + "rid": "win" + } + } } } }, "libraries": { + "AngleSharp/1.1.2": { + "sha512": "aRFpAqixbuj1Vmqy2hsWPF0PJygo1SfjvmpBvVWZv6i+/u+C/L4wDdwFIzyCGUbjqr61NsZdPNPqDE8wlmG2qA==", + "type": "package", + "path": "anglesharp/1.1.2", + "files": [ + ".nupkg.metadata", + ".signature.p7s", + "README.md", + "anglesharp.1.1.2.nupkg.sha512", + "anglesharp.nuspec", + "lib/net461/AngleSharp.dll", + "lib/net461/AngleSharp.xml", + "lib/net472/AngleSharp.dll", + "lib/net472/AngleSharp.xml", + "lib/net6.0/AngleSharp.dll", + "lib/net6.0/AngleSharp.xml", + "lib/net7.0/AngleSharp.dll", + "lib/net7.0/AngleSharp.xml", + "lib/net8.0/AngleSharp.dll", + "lib/net8.0/AngleSharp.xml", + "lib/netstandard2.0/AngleSharp.dll", + "lib/netstandard2.0/AngleSharp.xml", + "logo.png" + ] + }, "AtkSharp/3.24.24.95": { "sha512": "LnSfsc0y11gfzczZj5bnpwcFkXFZuVTSSd92ML/FcHIM7FU+cAfm1UkAonv5BdwTRhzDbNDE39vihao/k75sUA==", "type": "package", @@ -248,10 +311,53 @@ "pangosharp.3.24.24.95.nupkg.sha512", "pangosharp.nuspec" ] + }, + "System.Text.Encoding.CodePages/8.0.0": { + "sha512": "OZIsVplFGaVY90G2SbpgU7EnCoOO5pw1t4ic21dBF3/1omrJFpAGoNAVpPyMVOC90/hvgkGG3VFqR13YgZMQfg==", + "type": "package", + "path": "system.text.encoding.codepages/8.0.0", + "files": [ + ".nupkg.metadata", + ".signature.p7s", + "Icon.png", + "LICENSE.TXT", + "PACKAGE.md", + "THIRD-PARTY-NOTICES.TXT", + "buildTransitive/net461/System.Text.Encoding.CodePages.targets", + "buildTransitive/net462/_._", + "buildTransitive/net6.0/_._", + "buildTransitive/netcoreapp2.0/System.Text.Encoding.CodePages.targets", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net462/System.Text.Encoding.CodePages.dll", + "lib/net462/System.Text.Encoding.CodePages.xml", + "lib/net6.0/System.Text.Encoding.CodePages.dll", + "lib/net6.0/System.Text.Encoding.CodePages.xml", + "lib/net7.0/System.Text.Encoding.CodePages.dll", + "lib/net7.0/System.Text.Encoding.CodePages.xml", + "lib/net8.0/System.Text.Encoding.CodePages.dll", + "lib/net8.0/System.Text.Encoding.CodePages.xml", + "lib/netstandard2.0/System.Text.Encoding.CodePages.dll", + "lib/netstandard2.0/System.Text.Encoding.CodePages.xml", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "runtimes/win/lib/net6.0/System.Text.Encoding.CodePages.dll", + "runtimes/win/lib/net6.0/System.Text.Encoding.CodePages.xml", + "runtimes/win/lib/net7.0/System.Text.Encoding.CodePages.dll", + "runtimes/win/lib/net7.0/System.Text.Encoding.CodePages.xml", + "runtimes/win/lib/net8.0/System.Text.Encoding.CodePages.dll", + "runtimes/win/lib/net8.0/System.Text.Encoding.CodePages.xml", + "system.text.encoding.codepages.8.0.0.nupkg.sha512", + "system.text.encoding.codepages.nuspec", + "useSharedDesignerContext.txt" + ] } }, "projectFileDependencyGroups": { "net8.0": [ + "AngleSharp >= 1.1.2", "GtkSharp >= 3.24.24.95", "HtmlAgilityPack >= 1.11.71" ] @@ -293,6 +399,10 @@ "net8.0": { "targetAlias": "net8.0", "dependencies": { + "AngleSharp": { + "target": "Package", + "version": "[1.1.2, )" + }, "GtkSharp": { "target": "Package", "version": "[3.24.24.95, )" diff --git a/obj/project.nuget.cache b/obj/project.nuget.cache index dc1465a..95faf71 100644 --- a/obj/project.nuget.cache +++ b/obj/project.nuget.cache @@ -1,9 +1,10 @@ { "version": 2, - "dgSpecHash": "VIlMwTGgkTVOiBw98wHhoWW718Npjy/Ut4cwyxXucRy0cpVBB5mTlCmsEmH3z+G0GBCPZusaB8XMvWEhW8spNA==", + "dgSpecHash": "vtE4V6sCh/ezJsnT0M5QEo7noKBcpCVJldaAh0oCljeGBNXR9QdZzpjKNgqgY0x1ZubZYDuNfniHqXhJPPul/Q==", "success": true, "projectFilePath": "/home/retoor/projects/drnetapi/drnetapi.csproj", "expectedPackageFiles": [ + "/home/retoor/.nuget/packages/anglesharp/1.1.2/anglesharp.1.1.2.nupkg.sha512", "/home/retoor/.nuget/packages/atksharp/3.24.24.95/atksharp.3.24.24.95.nupkg.sha512", "/home/retoor/.nuget/packages/cairosharp/3.24.24.95/cairosharp.3.24.24.95.nupkg.sha512", "/home/retoor/.nuget/packages/gdksharp/3.24.24.95/gdksharp.3.24.24.95.nupkg.sha512", @@ -11,7 +12,8 @@ "/home/retoor/.nuget/packages/glibsharp/3.24.24.95/glibsharp.3.24.24.95.nupkg.sha512", "/home/retoor/.nuget/packages/gtksharp/3.24.24.95/gtksharp.3.24.24.95.nupkg.sha512", "/home/retoor/.nuget/packages/htmlagilitypack/1.11.71/htmlagilitypack.1.11.71.nupkg.sha512", - "/home/retoor/.nuget/packages/pangosharp/3.24.24.95/pangosharp.3.24.24.95.nupkg.sha512" + "/home/retoor/.nuget/packages/pangosharp/3.24.24.95/pangosharp.3.24.24.95.nupkg.sha512", + "/home/retoor/.nuget/packages/system.text.encoding.codepages/8.0.0/system.text.encoding.codepages.8.0.0.nupkg.sha512" ], "logs": [] } \ No newline at end of file