File Exchange Pick of the Week

Our best user submissions

Get HTML Table Data into MATLAB

Bob's pick this week is Get HTML Table Data into MATLAB by Jeremy Barry.

Lots of web pages have tabulated data. Suppose you want to grab some data to analyze. You could select text, copy to your clipboard, and import to MATLAB. But how would you do that automatically?

Take this stock snapshot from the example script Jeremy included to illustrate the 3-step process.

1. Navigate to web page with desired data.

web('http://finance.yahoo.com/q/ks?s=GOOG'), pause(10)

2. Parse the data.

getTableFromWeb, pause(10)

3. Extract the desired region of interest.

myTableData = getTableFromWeb(8)
myTableData = 
    'Market Cap (intraday)5:'              '149.14B'
    'Enterprise Value (Aug 19, 2010)3:'    '123.61B'
    'Trailing P/E (ttm, intraday):'        '20.32'  
    'Forward P/E (fye Dec 31, 2011)1:'     '14.98'  
    'PEG Ratio (5 yr expected):'           '1.10'   
    'Price/Sales (ttm):'                   '5.86'   
    'Price/Book (mrq):'                    '3.78'   
    'Enterprise Value/Revenue (ttm)3:'     '4.72'   
    'Enterprise Value/EBITDA (ttm)3:'      '11.42'  

If you noticed the MATLAB icons in the web browser, those indicate different parsed regions that you could select. If you click one of them from MATLAB's Browser that's exactly what it will do albiet manually of course. If you want to know which number corresponds to each data region, watch the status bar for the callback link when you hover over each one with your mouse. (If you noticed my screenshots are not perfectly synchronized with my published results then you might be very picky. :)

Comments?




Published with MATLAB® 7.10

|

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.