import requests
from bs4 import BeautifulSoup


def get_pypi_maintainers_list(pkg_name):
    """Retrieve list of PyPI maintainers via web scraping"""
    # Scrape regular PyPI package site
    url = "https://pypi.org/project/" + pkg_name
    html = requests.get(url)
    soup = BeautifulSoup(html.content, "html.parser")
    elements = soup.findAll("span", {"class": "sidebar-section__user-gravatar-text"})
    # Strip white space from all elements
    maintainers_full_list = [elem.string.strip() for elem in elements]
    # Remove duplicates via set, then sort a list of maintainers
    maintainers_list = sorted(list(set(maintainers_full_list)))
    return maintainers_list