Q:

Extract data from a specific cell in a table using BeautifulSoup?

I'm trying to extract the triage waiting times for a specific hospital to feed into other applications. Data from ALL local hospitals is available from: https://www.health.wa.gov.au/emergencyactivity/EDdata/edsv/
Here is the progress I have made so far:
import requests
from bs4 import BeautifulSoup

URL = 'https://www.health.wa.gov.au/emergencyactivity/EDdata/edsv/'

headers = {
    "User-Agent": 'Mozilla/5.0 (X11; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0'
}

page = requests.get(URL, headers=headers)

soup = BeautifulSoup(page.content, 'html.parser')

table_rows = soup.find_all('tr')

for tr in table_rows:
    td = tr.find_all('td')
    row = [i.text for i in td]
    print(row)

I want to extract only the triage time for Sir Charles Gairdner Hospital but have no clue how to do that. Any help would be much appreciated!

A:

You are almost there. Try something like this:
from bs4 import Tag

table_rows = soup.select('tr td')
for tr in table_rows:
    if tr.text ==  'Sir Charles Gairdner Hospital':
            for ns in tr.next_siblings:            
                if isinstance(ns,Tag):
                    print(ns.text)    

Another alternative:
table = soup.select('table')[0]
for row in table:
        if isinstance(row,Tag):
            tds = row.select('td')
            if len(tds)>0 and tds[0].text=='Sir Charles Gairdner Hospital':
                    for td in tds: 
                        print(td.text)

Output:
73
5
36

Edit:
To print just the triage waiting time for that location, use:
for tr in table_rows:
    if tr.text ==  'Sir Charles Gairdner Hospital':
            print(tr.next_sibling.text) #note: it's "next_sibling", not "siblings" this time

