I have successfully used selenium to scrape an html table which required a button click prior to scraping.
So selenium works, and successfully stores the html table as a variable ' r '.
I'm stumbling however getting this parsed into a pandas dataframe.
Like the URL, the dataframe should have 5 columns and about 30 rows.
Can anyone see where this is going wrong?
import pandas as pd
from selenium import webdriver
from bs4 import BeautifulSoup
browser = webdriver.Firefox(executable_path=r'/Users/computer_name/Documents/python/web_drivers/geckodriver')
browser.get('https://www.investing.com/equities/exxon-mobil-income-statement')
linkElem = browser.find_element_by_link_text('Annual')
linkElem.click()
r = browser.find_element_by_css_selector("#rrtable > table").get_attribute('innerHTML')
browser.quit()
soup = BeautifulSoup(r, 'html.parser')
df = pd.DataFrame(soup)
print(df)
Many thanks