ascii decoding

This commit is contained in:
hongtao 2015-03-04 11:25:26 +08:00
parent 6ea9ad95e0
commit 997f1eadf0
4 changed files with 32 additions and 39 deletions

32
README
View File

@ -50,31 +50,27 @@ Usage example
"ID": "22144"
}
]
>>> print json.dumps(getQuotes(['AAPL', 'GOOG']), indent=2)
>>> print json.dumps(getQuotes(['AAPL', 'VIE:BKS']), indent=2)
[
{
"Index": "NASDAQ",
"LastTradeWithCurrency": "129.09",
"LastTradeDateTime": "2015-03-02T16:04:29Z",
"LastTradePrice": "129.09",
"Yield": "1.46",
"LastTradeTime": "4:04PM EST",
"LastTradeDateTimeLong": "Mar 2, 4:04PM EST",
"Dividend": "0.47",
"LastTradeWithCurrency": "129.36",
"LastTradeDateTime": "2015-03-03T16:02:36Z",
"LastTradePrice": "129.36",
"LastTradeTime": "4:02PM EST",
"LastTradeDateTimeLong": "Mar 3, 4:02PM EST",
"StockSymbol": "AAPL",
"ID": "22144"
},
{
"Index": "NASDAQ",
"LastTradeWithCurrency": "571.34",
"LastTradeDateTime": "2015-03-02T16:04:29Z",
"LastTradePrice": "571.34",
"Yield": "",
"LastTradeTime": "4:04PM EST",
"LastTradeDateTimeLong": "Mar 2, 4:04PM EST",
"Dividend": "",
"StockSymbol": "GOOG",
"ID": "304466804484872"
"Index": "VIE",
"LastTradeWithCurrency": "17.10",
"LastTradeDateTime": "2015-03-03T13:30:30Z",
"LastTradePrice": "17.10",
"LastTradeTime": "1:30PM GMT+1",
"LastTradeDateTimeLong": "Mar 3, 1:30PM GMT+1",
"StockSymbol": "BKS",
"ID": "978541942832888"
}
]

View File

@ -35,30 +35,26 @@ From development repo (requires git)
"ID": "22144"
}
]
>>> print json.dumps(getQuotes(['AAPL', 'GOOG']), indent=2)
>>> print json.dumps(getQuotes(['AAPL', 'VIE:BKS']), indent=2)
[
{
"Index": "NASDAQ",
"LastTradeWithCurrency": "129.09",
"LastTradeDateTime": "2015-03-02T16:04:29Z",
"LastTradePrice": "129.09",
"Yield": "1.46",
"LastTradeTime": "4:04PM EST",
"LastTradeDateTimeLong": "Mar 2, 4:04PM EST",
"Dividend": "0.47",
"LastTradeWithCurrency": "129.36",
"LastTradeDateTime": "2015-03-03T16:02:36Z",
"LastTradePrice": "129.36",
"LastTradeTime": "4:02PM EST",
"LastTradeDateTimeLong": "Mar 3, 4:02PM EST",
"StockSymbol": "AAPL",
"ID": "22144"
},
{
"Index": "NASDAQ",
"LastTradeWithCurrency": "571.34",
"LastTradeDateTime": "2015-03-02T16:04:29Z",
"LastTradePrice": "571.34",
"Yield": "",
"LastTradeTime": "4:04PM EST",
"LastTradeDateTimeLong": "Mar 2, 4:04PM EST",
"Dividend": "",
"StockSymbol": "GOOG",
"ID": "304466804484872"
"Index": "VIE",
"LastTradeWithCurrency": "17.10",
"LastTradeDateTime": "2015-03-03T13:30:30Z",
"LastTradePrice": "17.10",
"LastTradeTime": "1:30PM GMT+1",
"LastTradeDateTimeLong": "Mar 3, 1:30PM GMT+1",
"StockSymbol": "BKS",
"ID": "978541942832888"
}
]

View File

@ -27,7 +27,8 @@ def request(symbols):
url = buildUrl(symbols)
req = Request(url)
resp = urlopen(req)
content = resp.read().decode().strip()
# remove special symbols such as the pound symbol
content = resp.read().decode('ascii', 'ignore').strip()
content = content[3:]
return content

View File

@ -2,12 +2,12 @@ from distutils.core import setup
setup(
name = 'googlefinance',
packages = ['googlefinance'], # this must be the same as the name above
version = '0.4',
version = '0.5',
description = 'Python module to get real-time (no delay) stock data from Google Finance API',
author = 'Hongtao Cai',
author_email = 'caiht.ht@gmail.com',
url = 'https://github.com/hongtaocai/googlefinance', # use the URL to the github repo
download_url = 'https://github.com/hongtaocai/googlefinance/tarball/0.4', # I'll explain this in a second
keywords = ['googlefinance', 'stock', 'price' , 'finance', 'google'], # arbitrary keywords
keywords = ['googlefinance', 'stock', 'price' , 'finance', 'google', 'real-time'], # arbitrary keywords
classifiers = [],
)