I am trying to scrape the financial data in the tables on https://www.barchart.com/stocks/quotes/IBM/income-statement/
Using inspect element I didn't see any XHR/fetch requests, but it looks like the data is generated via a js file named global-MBHFEFVQ.js, but its hard to follow the obfuscated code.
For some other data on the barchart.com website it looks like it can be scraped via an API call as explained in this post: How can I webscrape these ticker symbols from barchart.com?. But I'm not sure if this is the same for the income statement data. Any help is appreciated as I am new to webscraping.
I will be using php to scrape the data, but other languages would work too.
Right now I am just getting the whole page and extracting the data I'm interested in as substrings, but this is not ideal as I have to sort through all the other overhead in the website and have too loop through each 'reportPage' in the url to get data from each year.
$url = "https://www.barchart.com/stocks/quotes/IBM/income-statement/quarterly?reportPage=2";
$html = file_get_contents($url);
$date_start = stripos($html, "report__row-dates");
$date_end = stripos($html, "</tr>", $offset = $date_start);
$dates = substr($html, $date_start, $date_end - $date_start);
no idea where you got that from, it's all embedded in the HTML,
gives