返回列表 上一主題 發帖

[發問] 請問最近用vba下載twse大盤資料時,遇到一些網址的問題

[發問] 請問最近用vba下載twse大盤資料時,遇到一些網址的問題

本帖最後由 ashin1981 於 2016-8-19 21:16 編輯

各位大大你好!

小弟之前有用vba  excel web方式下載大盤指數(twse網站)到excel時都是正常的,但是最近在下載8月份資料時有一些問題,在8月份以前的網址都可以完整下載所有天數的資料,不曉得是不是twse的網站有改版嗎?

1. http://www.twse.com.tw/ch/trading/exchange/FMTQIK/genpage/Report201608/201608_F3_1_2.php?STK_NO=&myear=2016&mmon=08
2. http://www.twse.com.tw/ch/trading/exchange/FMTQIK/genpage/Report201607/201607_F3_1_2.php?STK_NO=&myear=2016&mmon=07

上面兩個網址,第1個是8月份的,可是他只能出現8/1~8/5的資料,第2個是7月份的,他可以出現7/1~7/30所有的資料,請問各位大大可以問是哪裡有問題嗎?
或可以用其他程式下載到excel。

程式在8月以前都可以正常顯示所有天數的資料,如下所示:

Sub 下載大盤指數Web()

    Dim WebSht大盤 As Worksheet
                    

    大盤指數URL = "URL;http://www.twse.com.tw/ch/trading/exchange/FMTQIK/genpage/Report" & y & m & "/" & y & m & "_F3_1_2.php?STK_NO=&myear=" & y & "&mmon=" & m
   
    Application.EnableCancelKey = xlErrorHandler
    Set WebSht大盤 = Sheets("大盤指數")

    WebSht大盤.Cells.Clear
   
    With WebSht大盤.QueryTables.Add(Connection:= _
         大盤指數URL, Destination:=WebSht大盤.[A2])
        .Name = "201507_F3_1_2.php?STK_NO=&myear=2015&mmon=07"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "8"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
        .Delete
    End With
   
101: ErrNo = Err.Number

Set WebSht大盤 = Nothing

End Sub

        靜思自在 : 天上最美是星星,人生最美是溫情。
返回列表 上一主題