返回列表 上一主題 發帖

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

gbkee,c_c_lai您好:

我也有上述的問題,也是證交所網站問題,但試了很久都沒有結果,可以請教高手是哪裡出錯了嗎? 謝謝您
http://www.twse.com.tw/ch/trading/exchange/TWT93U/TWT93U.php#
  1. Sub TEST123()
  2.     Dim YMD_day As String, N As Name, webURL As String
  3.     YMD_day = InputBox("輸入 民國年度日期 : 102/10/07", "下載特定日期的資料", Format(Date - 1, "E/MM/DD"))
  4.     With Sheets("下載資料")
  5.        For Each N In .Names
  6.             'N.Delete
  7.        Next
  8.         .Cells.Clear
  9.        GetData_URL = "URL;http://www.twse.com.tw/ch/trading/exchange/TWT93U/TWT93U.php?edition=ch&filename=genpage/A" & YMD_day & ".dat&type=csv"
  10.         'webURL = "URL; http://www.twse.com.tw/ch/trading/block/BFIAUU/BFIAUU.php?input_date=" & YMD_day & "&login_btn=查詢.dat"
  11.         With .QueryTables.Add(Connection:=GetData_URL, Destination:=.Range("A1"))
  12.             .WebSelectionType = xlSpecifiedTables
  13.             .WebFormatting = xlWebFormattingNone
  14.             .WebTables = "data_table"
  15.             .WebPreFormattedTextToColumns = True
  16.             .WebConsecutiveDelimitersAsOne = False
  17.             .WebSingleBlockTextImport = False
  18.             .WebDisableDateRecognition = False
  19.             .WebDisableRedirections = True
  20.             .Refresh BackgroundQuery:=False
  21.         End With
  22.     End With
  23. End Sub
複製代碼

TOP

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

各位高手您好,

因要抓先前已爬文,http://forum.twbts.com/viewthread.php?tid=10770,修改過後,資仍帶不出來,請想問各位高手是否php後面的語法使用有誤,謝謝大家^^

http://www.twse.com.tw/ch/trading/exchange/TWT93U/TWT93U.php
  1. Option Explicit
  2. Sub ExA()
  3.     With ActiveSheet
  4.         With .QueryTables.Add("URL;http://www.twse.com.tw/ch/trading/exchange/TWT93U/TWT93U.php#?combination_choice=sub&cno=1&input_date=103/02/25", .[A1])
  5.             .WebSelectionType = xlSpecifiedTables
  6.             .WebFormatting = xlWebFormattingNone
  7.             .WebTables = """data_table"""
  8.             .WebPreFormattedTextToColumns = True
  9.             .WebConsecutiveDelimitersAsOne = True
  10.             .WebSingleBlockTextImport = False
  11.             .WebDisableDateRecognition = False
  12.             .WebDisableRedirections = False
  13.             .Refresh BackgroundQuery:=False
  14.         End With
  15.     End With
  16. End Sub
複製代碼
  1. Sub TEST123()
  2.     Dim YMD_day As String, N As Name, webURL As String
  3.     YMD_day = InputBox("輸入 民國年度日期 : 102/10/07", "下載特定日期的資料", Format(Date - 1, "E/MM/DD"))
  4.     With Sheets("下載資料")
  5.        For Each N In .Names
  6.             'N.Delete
  7.        Next
  8.         .Cells.Clear
  9.        GetData_URL = "URL;http://www.twse.com.tw/ch/trading/exchange/TWT93U/TWT93U.php?edition=ch&filename=genpage/A" & YMD_day & ".dat&type=csv"
  10.         'webURL = "URL; http://www.twse.com.tw/ch/trading/block/BFIAUU/BFIAUU.php?input_date=" & YMD_day & "&login_btn=查詢.dat"
  11.         With .QueryTables.Add(Connection:=GetData_URL, Destination:=.Range("A1"))
  12.             .WebSelectionType = xlSpecifiedTables
  13.             .WebFormatting = xlWebFormattingNone
  14.             .WebTables = "data_table"
  15.             .WebPreFormattedTextToColumns = True
  16.             .WebConsecutiveDelimitersAsOne = False
  17.             .WebSingleBlockTextImport = False
  18.             .WebDisableDateRecognition = False
  19.             .WebDisableRedirections = True
  20.             .Refresh BackgroundQuery:=False
  21.         End With
  22.     End With
  23. End Sub
複製代碼

謝謝高手  太感謝了

TOP

heavenweaver 您好

我目前有二個網址
http://www.gretai.org.tw/ch/stock/statistics/monthly/st42.php
http://www.gretai.org.tw/ch/stock/statistics/monthly/st44.php

都是屬於上述的狀況,我想請教一下,是否有工具可以查詢?edition=ch&filename=genpage/A" & YMD_day & ".dat&type=csv" --的參數資料出來呢,謝謝

TOP

謝謝heavenweaver,又學到一招了

TOP

        靜思自在 : 發脾氣是短暫的發瘋。
返回列表 上一主題