<commit_before><commit_msg>Planet Wot statistics<commit_after>"""
Get World of Tanks statistics from Planet WOT
"""

from __future__ import unicode_literals, print_function, division
from bs4 import BeautifulSoup
import datetime
import time

server = 'eu'
baseurl = 'http://www.planetwot.com/playerStats/?name=%s&d=%s'


def command_wot(bot, user, channel, args):
    """Get the player info"""
    result = getinfo(bot, args)

    return bot.say(channel, result.encode("UTF-8"))


def getinfo(bot, player):
    """Parse the package status page"""
    url = baseurl % (player, server)
    r = bot.get_url(url)
    bs = BeautifulSoup(r.content)
    if not bs:
        return

    res = []

    table = bs.find("table", {'class': "statistics"})
    rows = list()
    for row in table.findAll("tr"):
        rows.append(row)

    for row in rows:
        cells = row.findChildren('td');
        if len(cells) >= 2:
            if cells[0].string is not None and cells[1].string is not None:
                res.append(cells[0].string)
                res.append(" ")
                res.append(cells[1].string)
                res.append(" ")

    str = "".join(res)
    return str
{'fraction_non_alphanumeric': 0.13593882752761258, 'fraction_numerical': 0.00594732370433305, 'mean_word_length': 2.6470588235294117, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7339587', 'n_tokens_mistral': 387, 'n_tokens_neox': 364, 'n_words': 103}