|
Sub test() '主體代碼
Dim strText As String
Header = Array("日期", "代碼", "名稱", "相關", "變動人", "變動股數", "成交均價", "變動金額(萬)", "變動原因", "變動比例(%)", "變動後持股數", "持股種類", "董監高人員姓名", "職務", "變動人與董監高的關係")
Cells.Clear
[a1].Resize(1, 15) = Header
Columns("B:B").NumberFormatLocal = "@"
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", "http://data.eastmoney.com/executive/list.html", False
.send
total_page = Split(Split(.responseText, "defjson: {pages:")(1), ",")(0)
End With
For y = 1 To total_page
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", "http://datainterface.eastmoney.com/EM_DataCenter/JS.aspx?type=GG&sty=GGMX&p=" & y & "&ps=50&js=var%20PIppoeZe={pages:(pc),data:[(x)]}&rt=47155997", False
.send
arr = Split(Split(.responseText, "var PIppoeZe={pages:" & total_page & ",data:[")(1), """")
For i = 1 To UBound(arr) Step 2
brr = Split(arr(i), ",")
Range("a65536").End(xlUp).Offset(1, 9) = brr(0)
Range("a65536").End(xlUp).Offset(1, 12) = brr(1)
Range("a65536").End(xlUp).Offset(1, 1) = WorksheetFunction.Text(brr(2), "000000")
Range("a65536").End(xlUp).Offset(1, 4) = brr(3)
Range("a65536").End(xlUp).Offset(1, 11) = brr(4)
Range("a65536").End(xlUp).Offset(1, 5) = Format(brr(6), "#,##0.00")
Range("a65536").End(xlUp).Offset(1, 10) = Format(brr(7), "#,##0.00")
Range("a65536").End(xlUp).Offset(1, 6) = brr(8)
Range("a65536").End(xlUp).Offset(1, 2) = brr(9)
Range("a65536").End(xlUp).Offset(1, 14) = brr(10)
Range("a65536").End(xlUp).Offset(1, 8) = brr(12)
Range("a65536").End(xlUp).Offset(1, 7) = Format(brr(13), "#,##0.00")
Range("a65536").End(xlUp).Offset(1, 13) = brr(14)
Range("a65536").End(xlUp).Offset(1, 0) = brr(5)
Next
End With
Next
End Sub
能力所限,六百多頁應該要很久很久,另外,http://datainterface.eastmoney.c ... amp;sty=GGMX&p=" & y & "&ps=50&js=var%20PIppoeZe={pages:(pc),data:[(x)]}&rt=47155997 最尾那個 RT 值我也找不到怎獲得,那個應該是該網站的登入記錄 |
|