r/learnpython • • Aug 31 '23

Web scraping with BeautifulSoup

2 Upvotes

I'm attempting to scrape the website below. I basically want to create a dataframe in python that looks like the table on the page.

https://www.eex.com/en/market-data/environmentals/futures

So far I have the following code:

url= 'https://www.eex.com/en/market-data/environmentals/futures'

r = requests.get(url)

soup = BeautifulSoup(r.text, 'lxml')

table = soup.find_all()

print(table)

I am however struggling to know what to put into the find_all() to pull back the values I need. For example, if I inspect the first settlement price, the html for that object is:

<td style="text-align: right;">86.24</td>

however if I do:

table = soup.find_all(td, style="text-align: right;")

print(table)

it pulls nothing back.

Would appreciate some guidance on this, I've tried watching tutorials online which I felt I understood until it came to doing my own example!

Thanks