I am new to python and need some guidance on extracting values from specific cells from a HTML table.
The URL that I am working on can be found here
I am looking to get the first 5 values only in the Month and Settlement columns and subsequently display them as:
"MAR 14:426'6"
Problem that I am facing is:
- How do I get the loop to start from the 3rd "TR" in the table
- How to get only values for td[0] and td[6].
- How to restrict the loop to only retrieve values for 5 rows
This is the code that I am working on:
tableData = soup1.find("table", id="DailySettlementTable")
for rows in tableData.findAll('tr'):
month = rows.find('td')
print month
Thank you and appreciate any form of guidance!
You probably want to use slicing.
Here's a modified snippet for your code: