|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
请教大神
1. 当 循环 For qq = 4 To 1 Step -1 qq=4时 ("table")(4) 是空值,会出错。这时应该跳出到qq=3的循环,如何做?
2. 表头取回的是乱码,如何转码?
谢谢!!!!!!!!
Sub sina()
Dim n, ii, jj, y, qq, k As Integer
For y = Year(Date) To Year(Date) - 2 Step -1
For qq = 4 To 1 Step -1
Set oDoc = CreateObject("htmlfile")
With 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
oDoc.body.innerHTML = .responsetext
Set r = oDoc.All.tags("table")(4).Rows
For ii = 1 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
End With
Next qq
Next y
End Sub
|
|