import requests
from bs4 import BeautifulSoup
import re


def get_opera_extension(extension_url):
    """
    Get the file url, extension name and the version of the Opera extension
    """
    response = requests.get(extension_url)
    html = response.text
    s = BeautifulSoup(html, "lxml")

    extension_version = s.findAll("dd")[2].text
    extension_name = re.findall(r"details\/(.*)\/", extension_url)[0]
    file_url = f"https://addons.opera.com/extensions/download/{extension_name}/"

    return file_url, extension_name, extension_version