- 帖子
- 142
- 主題
- 18
- 精華
- 0
- 積分
- 160
- 點名
- 138
- 作業系統
- win10 64位元
- 軟體版本
- office2003
- 閱讀權限
- 20
- 性別
- 男
- 來自
- 臺灣 高雄市
- 註冊時間
- 2015-7-18
- 最後登錄
- 2025-5-22
        
|
回復 49# no3-taco
以下內容可能有誤 因為還是出現訊息 "400"
Sub test()
Dim E As Object, AR(), i As Integer
AR = Array("http://www.yuantaetfs.com/#/RtNav/Index", "http://www.yuantaetfs.com/#/Home/Index")
'Ar = Array(網址:即時淨值,網址:國內指數) 網址置入陣列
ActiveSheet.UsedRange.Clear
For i = 0 To 1
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate AR(i)
Do While .Busy Or .readyState <> 4: DoEvents: Loop
If i = 0 Then '國內指數:不需按下同意鍵
Do
Set E = .Document.getElementByid("Agree")
Loop Until Not E Is Nothing
E.Click
End If
.Visible = False
Application.VBE.MainWindow.Visible = True
Application.VBE.Windows("即時運算").Visible = True
Stop '之後按下F5
Do
Do
Set E = .Document.getElementsByTagName("TABLE")(21 + i)
'即時淨值 第21個 "TABLE" ,'國內指數 第22個 "TABLE"
Debug.Print i, "e Is Nothing ->", E Is Nothing
Loop Until Not E Is Nothing
Debug.Print i, "e Is Nothing ->", E Is Nothing, "e.all.Length", E.all.Length
Loop Until E.all.Length >= IIf(i = 0, 415, 135) '
Stop '之後按下F5
Application.VBE.Windows("即時運算").Visible = False
Application.VBE.MainWindow.Visible = False
.Document.body.innerHTML = E.outerHTML
.ExecWB 17, 2 ' Select All
.ExecWB 12, 2 ' Copy selection
With ActiveSheet
.Range("A" & IIf(i = 0, 1, 27)).Select
.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
With .Range(IIf(i = 0, "D16:D17", "C27:C28")).Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End With
.Quit '關閉網頁
End With
Next
End Sub
|
|