<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def extract_canonical(bs4):
 """Extracting canonical url :param bs4: :return: """


    link_rel = bs4.select('link[rel="canonical"]')

    if link_rel.__len__() > 0:

        if link_rel[0].has_attr('href'):

            return link_rel[0]['href']

    return None