using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using AngleSharp;
using AngleSharp.Html.Dom;
using Newtonsoft.Json;
namespace Merit_Stats
{
class Program
{
public class Transaction
{
public string Day_of_Week { get; set; }
public string Month { get; set; }
public string Post { get; set; }
public string post_path { get; set; }
public int Sent_from { get; set; }
public int number_of_merit { get; set; }
public string time { get; set; }
}
public class Root
{
public int Sent_to { get; set; }
public int Total_Received_Merit { get; set; }
public ListTransactions { get; set; }
}
static async System.Threading.Tasks.Task Main(string[] args)
{
var json = "";
ListsumOfTotals;
using (WebClient wc = new WebClient())
{
json = wc.DownloadString("http://bitcointalk-merit-api.herokuapp.com/api/v0.1/received/375981");
}
var obj = JsonConvert.DeserializeObject>(json);
int i = 1;
foreach (var item in obj)
{
Console.WriteLine(item.Transactions.Count);
foreach (var child in item.Transactions)
{
Thread.Sleep(1000);
child.post_path = await GetBoardID("https://bitcointalk.org/index.php?topic=" + child.Post);
Console.WriteLine(child.Post + "(" + i + ")");
i++;
}
}
var list = obj.SelectMany(r => r.Transactions)
.GroupBy(t => t.post_path)
.Select(g => new { Board = g.Key, TotalLikes = g.Sum(t => t.number_of_merit) })
.ToList();
foreach (var item in list)
{
Console.WriteLine("Received {0} in {1}", item.TotalLikes, item.Board);
}
}
static async TaskGetBoardID(string post_id)
{
var config1 = Configuration.Default.WithDefaultLoader().WithDefaultCookies();
var UserProfile = post_id;
var context1 = BrowsingContext.New(config1);
var document1 = await context1.OpenAsync(UserProfile);
var boardsNames = document1.QuerySelectorAll("div#bodyarea div div.nav b a.nav").SkipLast(1);
var links = boardsNames.Select(m => m.TextContent);
var count = links.Count();
var loop = 0;
StringBuilder childBoards = new StringBuilder();
foreach (var item in links)
{
childBoards.Append(item.ToString() + " > ");
}
return childBoards.ToString();
}
}
}
Make sure to not change the Thread.Sleep part to a lower value otherwise your IP will get banned.