switch to integrated YQL code
This commit is contained in:
parent
12e2a445d7
commit
3d739483de
1 changed files with 5 additions and 9 deletions
|
@ -1,19 +1,15 @@
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from util import hook, http
|
from util import hook, http, web
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def stock(inp):
|
def stock(inp):
|
||||||
""".stock <symbol> -- gets stock information"""
|
"""stock <symbol> -- gets stock information"""
|
||||||
|
sym = inp.strip().lower()
|
||||||
|
|
||||||
url = ('http://query.yahooapis.com/v1/public/yql?format=json&'
|
query = "SELECT * FROM yahoo.finance.quote WHERE symbol=@symbol LIMIT 1"
|
||||||
'env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys')
|
quote = web.query(query, {"symbol": sym}).one()
|
||||||
|
|
||||||
parsed = http.get_json(url, q='select * from yahoo.finance.quote '
|
|
||||||
'where symbol in ("%s")' % inp) # heh, SQLI
|
|
||||||
|
|
||||||
quote = parsed['query']['results']['quote']
|
|
||||||
|
|
||||||
# if we dont get a company name back, the symbol doesn't match a company
|
# if we dont get a company name back, the symbol doesn't match a company
|
||||||
if quote['Change'] is None:
|
if quote['Change'] is None:
|
||||||
|
|
Reference in a new issue