Search code examples
matlabspecial-charactersurlread

urlread pound sign (#) doesn't work


Trying to read in the pricing lists under pricing information tab:

urlread( ' http://www.cefconnect.com/Details/Summary.aspx?Ticker=KYE#pricing ' )

But in url '#pricing' doesn't help.

Any suggestions?


Solution

  • As already pointed out by Darin, it's no use adding #pricing to the URL. The web page uses client-side techniques to switch between tabs; not something that can be used by urlread.

    Summary.aspx always returns all tabs together as one big page. CSS and JavaScript make it look like a collection of tabs, when opened in a web browser.

    Use the developer toolbar of your web browser to inspect the web page. For example in Google Chrome, just right-click on the section you are interested in, and select 'inspect element'.

    I don't know what you are going to do with the result of urlread, but you'll probably have to do some parsing to distill the information you need from the HTML clutter.

    Please note Summary.aspx launches additional HTTP requests to retrieve additional data. Use the 'Network' tab of Chrome's developer toolbar to analyze that behavior. For example, the following request is made when you click 'GO' after adjusting the pricing history filter criteria.

    http://www.cefconnect.com/Resources/TableData/?Type=PricingHistory&Cusip=48660P104&param0=1M&param1=06/06/2014

    At first, this seems to complicate the whole matter, but it may actually be a great opportunity. You can call urlread with the URL above, and get some data in JSON format, which is far less cluttered than HTML. Adjust the parameters to get different data. I'm not sure what 48660P104 is; it might be an internal representation of KYE. You may want to use an initial HTTP request to Summary.aspx to retrieve that code; you'll notice the webpage is littered with URLs containing the same parameter Cusip.