码迷,mamicode.com
首页 > 编程语言 > 详细

Excel_Vba 上海证券交易所个股历史各月成交概况

时间:2015-07-28 13:00:13      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:vba   excel_vba   json   

Sub 上海证券交易所个股历史各月成交概况()
    On Error Resume Next
    Cells.Clear
    [a1:aa1] = Array("名称", "代码", "年月", "月初开市价", "月末收市价", "成交价最高", "时间", "成交价最低", "时间", "月度总成交量(万股)", "最高", "时间", "最低", "时间", "月度总成金额(万元)", "最高", "时间", "最低", "时间", "成交总笔数(万笔)", "换手率", "月末平均市盈率", "涨跌幅%", "振幅%", "月末市价总值", "月末流通市值", "该月累计交易日")
    arr = Array("productName", "id", "txDate", "openPrice", "closePrice", "maxHighPrice", "maxHighPriceDate", "minLowPrice", "minLowPriceDate", "totalVol", "maxTrVol", "maxTrVolDate", "minTrVol", "minTrVolDate", "totalAmt", "maxTrAmt", "maxTrAmtDate", "minTrAmt", "minTrAmtDate", "totalTx", "totalExchRate", "closeProfitRate", "change", "totalChange", "closeMarketValue", "closeNegoValue", "totalTxDate")
    Set js = CreateObject("msscriptcontrol.scriptcontrol")
    js.Language = "JavaScript"
    With CreateObject("WinHttp.WinHttpRequest.5.1")
        .Open "GET", "http://query.sse.com.cn/security/fund/queryMonthQuat.do?jsonCallBack=a&productId=600765&inYear=2014&prodType=1&pageHelp.pageSize=20&_=" & js.eval("Math.round(new Date().getTime())"), True
        .setRequestHeader "X-HttpWatch-RID", "11777-10185"
        .setRequestHeader "Referer", "http://www.sse.com.cn/assortment/stock/list/stockdetails/turnover/turnovermonth_index.shtml?COMPANY_CODE=600765&inYear=2014"
        .setRequestHeader "Connection", "Keep-Alive"
        .send
        t1 = Timer
        Do Until Timer > t1 + 2
            DoEvents
        Loop
        tt = Replace(Replace(.responseText, "(", "="), ")", "")
        js.AddCode Replace(Replace(.responseText, "(", "="), ")", "")
        n = js.eval("a.result.length")
        For i = 0 To n - 1
            For j = 0 To 26
                Cells(i + 2, j + 1) = js.eval("a.result[" & i & "]." & arr(j))
            Next j
        Next i
    End With
End Sub

版权声明:本文为博主原创文章,未经博主允许不得转载。

Excel_Vba 上海证券交易所个股历史各月成交概况

标签:vba   excel_vba   json   

原文地址:http://blog.csdn.net/a814153a/article/details/47103565

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!