from bs4 import BeautifulSoup
from typing import Union


def _find_wallpaper_urls(
    page_html: BeautifulSoup,
    title: str,
) -> Union[list, None]:
    """
    Parse HTML and search URLs of the wallpaper.

    One wallpaper has two URLs. For wallpapers with and without calendar.

    Args:
        page_html (BeautifulSoup): HTML for parsing.
        title (str): title in 'Wallpaper name - resolution' format.
            Example - 'Beautiful image - 1920x1080'.

    Returns:
        Union[list, None]: URLs of wallpapers or
            'None' if URLs of wallpapers does not exist.
    """
    wallpaper_urls_tags = page_html.find_all(
        lambda tag:
        tag.name == "a" and
        tag.get("title") == title,
    )

    if wallpaper_urls_tags:
        return [url_tag.get("href") for url_tag in wallpaper_urls_tags]
    return None