'Code working in jupyter notebook but not in colab

I'm trying web scrapping and I have the following piece of code that works perfectly fine in Jupyter Noteebook, but it doesn't run while using Colab.

def get_price_ripley_con_tarjeta(url): 
    r = requests.get(url)
    soup = BeautifulSoup(r.text, 'html.parser')
    price = soup.find('div',{'class':'product-price-container product-internet-price-not-best'}).text
    return price

get_price_ripley_con_tarjeta('https://simple.ripley.cl/kit-stream-mic-stand-antipop-sound-card-jammin-pro-2000385921783p?color_80=negro&s=mdco')

The error is

AttributeError                            Traceback (most recent call last)
<ipython-input-100-40e0f990795c> in <module>()
      5     return price
      6 
----> 7 get_price_ripley_con_tarjeta('https://simple.ripley.cl/kit-stream-mic-stand-antipop-sound-card-jammin-pro-2000385921783p?color_80=negro&s=mdco')

<ipython-input-100-40e0f990795c> in get_price_ripley_con_tarjeta(url)
      2     r = requests.get(url)
      3     soup = BeautifulSoup(r.text, 'html.parser')
----> 4     price = soup.find('div',{'class':'product-price-container product-internet-price-not-best'}).text
      5     return price
      6 

AttributeError: 'NoneType' object has no attribute 'text'

Anybody knows why? is it something related to cookies or what? Really appreciate it!!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source