Scraping Yahoo Finance for Earnings data

9 次查看(过去 30 天)
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 个评论
David
David 2020-11-7
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

请先登录,再进行评论。

回答(0 个)

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by