import helpers

def get_title(soup):
    try:
        title = soup.find("span", attrs={"id":'productTitle'})
        title_value = title.string
        title_string = title_value.strip()
    except AttributeError as err:
        helpers.logging.info(f"Couldn't get title: {err}")
        title_string = ""
        
    return title_string

def get_price(soup):
    try:
        price = soup.find("span", attrs={'class':'a-offscreen'}).string.strip()
        # A veces mete el título en el precio
        if "€" not in price:
            price = "N/A"
    except AttributeError:
        price = "N/A"	

    return price

def get_image(soup):
    try:
        image = soup.find("img", attrs={'id':'landingImage'})
        image = image.get('src')
    except AttributeError:
        image = "N/A"	

    return image