1

I am new using python and I am trying to get some values from a table in a webpage, I need to get the values in yellow from the web page:

enter image description here

I have this code, it is getting all the values in the "Instruments" column but I don't know how to get the specific values:

body = soup.find_all("tr")
for Rows in body:
        RowValue = Rows.find_all('th')
        if len(RowValue) > 0:
            CellValue = RowValue[0]     
            ThisWeekValues.append(CellValue.text)

any suggestion?

Pablo Gûereca
  • 725
  • 1
  • 9
  • 23
  • 1
    where's the link/HTML? – Abhishek Rai Nov 16 '20 at 19:29
  • https://www.federalreserve.gov/releases/h15/ – Pablo Gûereca Nov 16 '20 at 19:30
  • 1
    `pd.read_html('https://www.federalreserve.gov/releases/h15/')` in case you are familiar with pandas. Have a look at [Extracting data from HTML table](https://stackoverflow.com/q/11790535/7259176) and [pandas.read_html](https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.read_html.html) – upe Nov 16 '20 at 19:46

1 Answers1

1
ids = driver.find_elements_by_xpath('//*[@id]')

if 'Your element id`  in ids:
    Do something

One of the ways could be this, since only id is different.

Abhishek Rai
  • 2,159
  • 3
  • 18
  • 38