Created
January 13, 2015 08:13
-
-
Save ywchiu/d726e0d042031a10bf10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
url ="http://www.gretai.org.tw/web/stock/aftertrading/daily_trading_info/st43_result.php?l=zh-tw&d=%s&stkno=3290&_=1421136081459" | |
dt = "104/1" | |
from datetime import timedelta | |
from dateutil.relativedelta import relativedelta | |
getyear = dt.split('/',1) | |
bctime = str(int(getyear[0]) + 1911) +"/"+ getyear[1] | |
for i in range(1,10): | |
ts = (datetime.strptime(bctime, "%Y/%m") - relativedelta(months=i)).strftime("%Y/%m") | |
ts2 = ts.split('/',1) | |
ts3 = str(int(ts2[0]) - 1911) + '/' + ts2 [1] | |
res = requests.get(url %(ts3)) | |
j = json.loads(res.text) | |
for price in j['aaData']: | |
print price[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment