That's strange, I just tested the code again, and it worked for me.

One thing we can do is try it in piecemeal:

Here is a sample that just scrapes the total ESG score for Microsoft:

from bs4 import BeautifulSoup

import pandas as pd

import requests

import ipywidgets as widgets

from ipywidgets import interact

web_data = requests.get('https://finance.yahoo.com/quote/MSFT/sustainability?p=MSFT').text

soup = BeautifulSoup(web_data, 'html.parser')

esg_score = soup.find('div', {'class':'Fz(36px) Fw(600) D(ib) Mend(5px)'})

print(esg_score.text)

Try testing that out. It should output an ESG score of 16.

Stumbled into a data-centric role several years ago and have not looked back! Passionate about leveraging technology to uncover answers and improve the world.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store