|
请测试
Sub sina()
[a2:g1500] = ""
Dim n, ii, jj, y, qq, k As Integer
k = 1
For y = Year(Date) To Year(Date) - 2 Step -1
For qq = 4 To 1 Step -1
Set oDoc = CreateObject("htmlfile")
With CreateObject("Microsoft.XMLHTTP") 'CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "GET", "http://vip.stock.finance.sina.com.cn/corp/go.php/vMS_MarketHistory/stockid/000001/type/S.phtml?year=" & y & "&jidu=" & qq, False
.Send
' .WaitForResponse
V = StrConv(.responseBody, vbUnicode, &H804)
oDoc.body.innerHTML = V '.responsetext
End With
V1 = InStrRev(V, "季度历史交易")
If V1 < 1 Then GoTo DDD
Set r = oDoc.All.tags("table")(4).Rows
For ii = 2 To r.Length - 1
k = k + 1
For jj = 0 To r(ii).Cells.Length - 1
Cells(k, jj + 1) = r(ii).Cells(jj).innerText
Next jj
k = [a65536].End(3).Row
Next ii
Set r = Nothing
DDD:
Next qq
Next y
End Sub
|
|