Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2008
    Posts
    19
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Embed Market Stock Bar

    Hello all, I'm looking for a Market stock bar similar
    to http://www.bloomberg.com/

    I've been looking around and can't find any API's or examples.

    Could someone point me in the right direction?

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    I found this information on Stackoverflow:
    Code:
    <script type="text/javascript" src="jquery-1.5.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
                var symbol='goog';
                var callback = function(data) {
                        var price=data.query.results.span[0].content;
                        alert('Stock Price: ' + price);
                    };
    
                var url = 'http://query.yahooapis.com/v1/public/yql';
                // this is the lovely YQL query (html encoded) which lets us get the stock price:
                // select * from html where url="http://finance.yahoo.com/q?s=goog" and xpath='//span[@id="yfs_l10_goog"]'
                var data = "q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Ffinance.yahoo.com%2Fq%3Fs%3D" + symbol + "%22%20and%20xpath%3D'%2F%2Fspan%5B%40id%3D%22yfs_l10_" + symbol + "%22%5D'&format=json";
                $.getJSON(url, data, callback);
        });
    </script>
    It uses jquery, but if you're not already using jquery you could modify this to work without it...
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •