Scraping Yahoo Finance for Earnings data

6 vues (au cours des 30 derniers jours)
David
David le 9 Oct 2020
Commenté : David le 7 Nov 2020
I'm trying to scrape Yahoo Finance for earnings data. The address for Apple would be Yahoo Finance AAPL . Using webread and urlread I get returned an info page, but not the data displayed on screen. I'm not sure why this is, the data I want appears in the source code. I only have experience of scraping direct web html pages which are increasingly rare. Can anyone help with this?
Thanks.
  1 commentaire
David
David le 7 Nov 2020
Instead of trying to scrape the website which uses Java script I decided on a different approach. The following code opens a CNBC Dow 30 web page, uses Ctrl-A and Ctrl-C to copy the page into clipborad. This is imported into Matlab. Its not fancy, but it works! Make sure you have already run Chrome (or whatever browser you use) as it speeds up the code response time. Data will be in A.
h = actxserver('WScript.Shell');
h.Run('chrome'); %Invokes chrome.exe
pause(5); %Waits for the application to load.
h.AppActivate('chrome'); %Brings chrome to focus
h.SendKeys('https://www.cnbc.com/dow-30/~'); %send web address
pause(5);
h.SendKeys('^a'); % highlight file
pause(2)
h.SendKeys('^c'); % copy file
pause(3)
A = importdata('-pastespecial'); %import formatted data
pause(3)
h.SendKeys('%{F4}'); %close chrome

Connectez-vous pour commenter.

Réponses (0)

Produits


Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by