Hey everyone, I have been fighting with this problem for a few months now and still can not find an option that I am able to get to work properly. Does anyone know of a way to display a companies stock price? I have found a few but cant get them to work as I need it to use javascript not php Thanks , Chris
<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>
Thanks for putting it into a codepen for me. I am searching the code and can not find where I can change the stock symbol. I need it to find PRW which is Petrowest Corporation.
haha I know what you mean! I actually had to dig really deep into the Yahoo Finance stuff to make any sense of their crazy YQL language. It took a lot of trial and error!
@TheDoc well the stock ticker works awesome! only one little problem... haha not working on Internet Explorer. Any idea on how to fix this or should I look at buying one. http://petrowest.squarespace.com/home/
Can anyone see a way to get rid of the "Ads by Google, Stock Quotes, Shares Stock" on my stock ticker? I did have it gone for a minute and then things showed up again.
I have been fighting with this problem for a few months now and still can not find an option that I am able to get to work properly.
Does anyone know of a way to display a companies stock price? I have found a few but cant get them to work as I need it to use javascript not php
Thanks ,
Chris
http://stackoverflow.com/questions/5150040/stock-quotes-with-javascript
http://developer.yahoo.com/finance/
I'm guessing because it's on the TSE, so 'TO' for Toronto.
http://petrowest.squarespace.com/home/