I'm having trouble returning one particular table (the one titled 'BRN Substantial Shareholders') from this webpage - https://www.intelligentinvestor.com.au/shares/asx-brn/brainchip-holdings-ltd
I'm able to return all the tables using the below code.
html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')
all_tables = soup.find_all('table')
I've tried two different methods to try and scrape using bs but I can't seem to find a way - am I doing something wrong? Both of these output an empty list.
Method 1
# Scrape the substantial holder list
html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')
sub_headers = []
sub_holdings = []
for found_table in soup.find_all('table', class_=f'{ticker_code} + "Substantial Shareholders"'):
sub_headers = found_table.find_all('th').append(sub_headers)
sub_holdings = found_table.find_all('td').append(sub_holdings)
print(sub_headers)
print(sub_holdings)
Method 2
# Scrape the substantial holder list
html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')
all_headers = soup.find_all("th", class_=f"{ticker_code} Substantial Shareholders")
all_holdings = soup.find_all("tr", class_=f"{ticker_code} Substantial Shareholders")
sub_headers = []
sub_holdings = []
for header in all_headers:
sub_headers.append(header.text)
for holding in all_holdings:
holding.append(sub_holdings.text)
print(sub_headers)
print(sub_holdings)
To only scrape the table with the words "BRN Substantial Shareholders", you can use a CSS selector to locate that table with:
table = soup.select_one("div:nth-of-type(11) table")
Found a much simpler method using below.
sub_table = pd.read_html(current_url, match='Holding') print(sub_table)
How to prevent a token created with OAuth 2.0 from expiring?
I'm struggling with a practice problem below where I'm confused as to what the definitions would look like
some of example of schemaI have different constraints based on type
I'm trying to take the first 200 rows of my dataframe and pass it through a UMAP fit method but I'm not able to get it to shape the way I want at (200,2)Should I add an embedding parameter?