import requests


def get_wikipedia_url_with_pageid(pageid):
    """Return url of wikipedia page according to the given pageid.

    :param: pageid from wikipedia API
    :type: <str>
    :return: Return FIELD_URL or ""
    :rtype: <str>
    """

    URL = "https://fr.wikipedia.org/w/api.php?action=query&prop=info&pageids={}&inprop=url&format=json"

    try:
        return requests.get(
            URL.format(pageid)
        ).json()["query"]["pages"][str(pageid)]["canonicalurl"]
    except:
#        print("NO URL !")
        return ""