New version.

This commit is contained in:
retoor 2024-12-17 12:10:58 +01:00
parent 7fb519f419
commit c9065bcf38
19 changed files with 201 additions and 18 deletions

View File

@ -1,24 +1,45 @@
using HtmlAgilityPack;
using System;
using System.Linq;
using AngleSharp;
class DrApi {
class DrApi
{
public static async Task<string> get_rants (string url) {
public static async Task<List<string>> DomQueryClass(string htmlContent, string className)
{
var config = Configuration.Default;
var context = BrowsingContext.New(config);
var document = await context.OpenAsync(req => req.Content(htmlContent));
string response = await HTTP.get(url).ConfigureAwait(false);;
var elements = document.QuerySelectorAll($".{className}");
return elements.Select(el => el.TextContent).ToList(); //OuterHtml).ToList()
}
public static async Task<string> 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;
}

View File

@ -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);
}
}
}
};
};

View File

@ -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"
}
}
}

Binary file not shown.

Binary file not shown.

View File

@ -8,6 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AngleSharp" Version="1.1.2" />
<PackageReference Include="GtkSharp" Version="3.24.24.95" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.71" />
</ItemGroup>

View File

@ -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")]

View File

@ -1 +1 @@
f0a018514b0ac9989cefd4e8304d6c22b9ba22f2036bcbdc20cd35b98e0929b3
885952bf447ff1bea5505c35b1c8231624b933a12c032ef1d33f249f3074a7e0

View File

@ -1 +1 @@
5e3e99658f7cc8eb082cd7c6cd551b3ff500dd816707657a9c3f556f838b6d19
cb53997bd4f956d6fe419ccaf3b77c877689b448a89934fef62624a0029ccea3

View File

@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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, )"

View File

@ -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, )"

View File

@ -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": []
}