|
using HtmlAgilityPack;
|
|
using System;
|
|
using System.Linq;
|
|
using AngleSharp;
|
|
|
|
class DrApi
|
|
{
|
|
|
|
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));
|
|
|
|
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 = 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"){
|
|
|
|
// Console.WriteLine(node.InnerText);
|
|
//}
|
|
//}
|
|
return null;
|
|
}
|
|
|
|
}
|