import requests
from bs4 import BeautifulSoup
import re
import itertools


def translate(word: str) -> list:
    """Translate word

    Arguments:
        word {str} -- the word to be translated

    Returns:
        [list] -- list of translations
    """
    req = requests.get(f"https://www.diki.pl/slownik-angielskiego?q={word}")
    page = BeautifulSoup(req.text, "html.parser")
    find_li = page.find_all("li", re.compile("meaning*"))
    find_a = [x.find_all("a", "plainLink") for x in find_li]
    flatten = itertools.chain().from_iterable(find_a)
    translated: list = [x.text for x in flatten]
    return translated