Semperdickus Veteran - Summoner*
Posts : 54 Join date : 2016-02-17
| Subject: Clan Activity Tool Sun Jun 05, 2016 5:27 pm | |
| So I wanted to make something to track member activity without having to be online all the time. I know how bnscoffee works after looking into his code so I had a decent starting point. Data is extracted from this site: http://eu-bns.ncsoft.com/ingame/bs/character/profile?c=Gintok%C3%AESo I wrote a C# console that runs down certain data from a list of players and converts it to an excel workbook that's stored on my pc. Here's the code: - Spoiler:
using CsQuery; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using System.Net; using System.Text; namespace ConsoleApplication2 { class Program { public static string urlStatic = "http://eu-bns.ncsoft.com/ingame/bs/character/profile?c="; //get link static void Main(string[] args) { List datas = new List(); List players = new List() //clan list { "Gintokî", "Lukejka", "Inkz", "Poizun", "Trezolina", "DontHitNoobs", "Semperdickus"
};
foreach (string s in players) { try { playerData data = getPlayerData(s); if (data != null) datas.Add(data); } catch { } } datas = datas.OrderByDescending(x => x.AP).ToList();
string result = ""; foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(datas[0])) { result += descriptor.Name + ";"; } foreach (playerData pD in datas) { result += "\r\n"; foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(pD)) { string name = descriptor.Name; object value = descriptor.GetValue(pD); result += value + ";"; }
} File.WriteAllText("C:\\Users\\Terence\\Documents\\Yurozuya\\bns.csv", result); //save to this location }
public static string getHtml(string urlAddress) { string data = ""; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress); HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK) { Stream receiveStream = response.GetResponseStream(); StreamReader readStream = null;
if (response.CharacterSet == null) { readStream = new StreamReader(receiveStream); } else { readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet)); }
data = readStream.ReadToEnd();
response.Close(); readStream.Close(); } return data; } catch { return data; } }
public class playerData { public string Name { get; set; } public string AP { get; set; } public string HP { get; set; } public string Class { get; set; } public string Level { get; set; } public string Weapon { get; set; } public string Earring { get; set; } public string Necklace { get; set; } public string Bracelet { get; set; } public string Ring { get; set; } public string Belt { get; set; } public string Soul { get; set; } public playerData() { } public playerData(string n) { Name = n; } }
public static playerData getPlayerData(string name) { try { string html = getHtml(urlStatic + name); CQ dom = CQ.Create(html); var a = dom[".desc li"][0].InnerText; playerData data = new playerData(name); var test = dom[".wrapWeapon"];
data.Level = dom[".desc li"].Eq(1).Text().Trim(); data.Weapon = dom[".wrapWeapon"].Find(".name").Text().Trim(); data.Earring = dom[".earring"].Find(".name").Text().Trim(); data.Necklace = dom[".necklace"].Find(".name").Text().Trim(); data.Bracelet = dom[".bracelet"].Find(".name").Text().Trim(); data.Ring = dom[".ring"].Find(".name").Text().Trim(); data.Belt = dom[".belt"].Find(".name").Text().Trim(); data.Soul = dom[".soul"].Find(".name").Text().Trim(); data.AP = dom[".stat-point"].Eq(1).Text().Trim(); data.Class = dom[".desc"].Find("li").Eq(0).Text().Trim(); data.HP = dom[".stat-point"].Eq(45).Text().Trim();
//Remove Stage 10 text if(data.Weapon.Contains(" - Stage 10")) data.Weapon = data.Weapon.Replace(" - Stage 10", "");
if (data.Necklace.Contains(" - Stage 10")) data.Necklace = data.Necklace.Replace(" - Stage 10", "");
if (data.Ring.Contains(" - Stage 10")) data.Ring = data.Ring.Replace(" - Stage 10", "");
if (data.Belt.Contains(" - Stage 10")) data.Belt = data.Belt.Replace(" - Stage 10", "");
if (data.Bracelet.Contains(" - Stage 10")) data.Bracelet = data.Bracelet.Replace(" - Stage 10", "");
if (data.Earring.Contains(" - Stage 10")) data.Earring = data.Earring.Replace(" - Stage 10", "");
if (data.Level.Contains("Level 50 • ")) data.Level = data.Level.Replace("Level 50 • ", "");
return data; } catch { return null; } } } }
Here's the output (you can sort hwever you want in exel): - Spoiler:
I'll upgrade this as we go. Here's a list of thing I will be adding:
- Add clan ranks and sort on clan rank Done!
- Make a new tab with current date everytime I run the program so you can manually see what changed overtime
- See if anything changed compared to last week (new table with number showing how may weeks/times run nothing changed) Done!
- See if I can get this uploaded to google docs so other people can edit it and check it out for themselves. Otherwise I can just make a weekly thread.
- I would like more suggestions
Edit: Pretty much have everything done. Will be running it every sunday and copy the results to a google sheet. Will post the link when I have everything ready. Next step is selling it to pewpewpew for 100g I made this topic to let you know and to write down any ideas I get for future expansion.
Last edited by Semperdickus on Sun Jun 05, 2016 8:05 pm; edited 2 times in total | |
|
Gintoki Leader - Blade Master
Posts : 90 Join date : 2016-02-16
| Subject: Re: Clan Activity Tool Sun Jun 05, 2016 5:57 pm | |
| | |
|