返回列表 上一主題 發帖

有關EXCEL VBA 抓取不到完整網址CSV問題

請試用一下吧

Sub TWT93U()
'
'
' 信用額度總量管制餘額表  @ TWSE 臺灣證券交易所 ﹥交易資訊 ﹥融資融券與可借券賣出額度 ﹥融券借券賣出餘額
' http://www.twse.com.tw/ch/trading/exchange/TWT93U/TWT93U.php
Dim YMD_day As String, N As Name, webURL As String
    YMD_day = Format(Date, "E/MM/DD")
    With Sheets("Sheet1")
        For Each N In .Names
            N.Delete
        Next
        .Cells.Clear
        webURL = "URL;http://www.twse.com.tw/ch/trading/exchange/TWT93U/TWT93U.php?input_date=" & YMD_day & "&login_btn=查詢.dat"
        With .QueryTables.Add(Connection:=webURL, Destination:=.Range("A1"))
            .WebSelectionType = xlSpecifiedTables
            .WebFormatting = xlWebFormattingNone
            .WebTables = "7,9"
            .WebPreFormattedTextToColumns = True
            .WebConsecutiveDelimitersAsOne = False
            .WebSingleBlockTextImport = False
            .WebDisableDateRecognition = False
            .WebDisableRedirections = True
            .Refresh BackgroundQuery:=False
        End With
    End With
End Sub
很抱歉,我是小學生,不能下載檔案,是個小屁孩!

TOP

回復 35# gto1208
改好了,請試用吧!

    Sub TEST123()
        Dim YMD_day As String, N As Name, webURL As String
        YMD_day = InputBox("輸入 民國年度日期 : 102/10/07", "下載特定日期的資料", Format(Date - 1, "E/MM/DD"))
        With Sheets("下載資料")
           For Each N In .Names
                'N.Delete
           Next
            .Cells.Clear
            GetData_URL = "URL;http://www.twse.com.tw/ch/trading/exchange/TWT93U/TWT93U.php?edition=ch&filename=genpage/A" & YMD_day & ".dat&type=csv"
            'webURL = "URL; http://www.twse.com.tw/ch/trading/block/BFIAUU/BFIAUU.php?input_date=" & YMD_day & "&login_btn=查詢.dat"
            With .QueryTables.Add(Connection:=GetData_URL, Destination:=.Range("A1"))
                 .WebSelectionType = xlSpecifiedTables
                 .WebFormatting = xlWebFormattingNone
                 .WebTables = "9"
                 .WebPreFormattedTextToColumns = True
                 .WebConsecutiveDelimitersAsOne = False
                 .WebSingleBlockTextImport = False
                 .WebDisableDateRecognition = False
                 .WebDisableRedirections = True
                 .Refresh BackgroundQuery:=False
             End With
            End With
        End With
    End Sub
很抱歉,我是小學生,不能下載檔案,是個小屁孩!

TOP

heavenweaver 您好
我目前有二個網址
http://www.gretai.org.tw/ch/stock/statistics/monthly/st42.php
都是屬於上述的狀況,我想請教一下,是否有工具可以查詢?edition=ch&filename=genpage/A" & YMD_day & ".dat&type=csv" --的參數資料出來呢,謝謝gto1208 發表於 2014-2-27 11:11

最直接的就是用瀏覽器本身所提供的網頁開發者工具如Chrome的檢查元素或FireFox的檢測元素
http://www.gretai.org.tw/ch/stock/statistics/monthly/st42.php

Request URL:http://www.gretai.org.tw/ch/stock/statistics/monthly/result_st42.php?timestamp=1393573668432
Form Data
            ajax=true&input_stock_code=3260
兩者合併
http://www.gretai.org.tw/ch/stock/statistics/monthly/result_st42.php?ajax=true&input_stock_code=3260

http://www.gretai.org.tw/ch/stock/statistics/monthly/st44.php

http://www.gretai.org.tw/ch/stock/statistics/monthly/result_st44.php?ajax=true&yy=2014&input_stock_code=3260
很抱歉,我是小學生,不能下載檔案,是個小屁孩!

TOP

        靜思自在 : 脾氣嘴巴不好,心地再好也不能算是好人。
返回列表 上一主題