- 帖子
- 102
- 主題
- 17
- 精華
- 0
- 積分
- 129
- 點名
- 0
- 作業系統
- windows
- 軟體版本
- 2010
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2012-5-16
- 最後登錄
- 2020-9-2
|
本帖最後由 lalalada 於 2012-7-27 15:58 編輯
證交所網站竟然改版了ˊˋ 才剛寫好的說
完全沒有新手的好運....
ActiveSheet.name = sheetname
webURL = "URL; http://bsr.twse.com.tw/bshtm/bsContent.aspx? StartNumber=2498&FocusIndex=All_21"
'webURL = "URL; http://bsr.twse.com.tw/bshtm/bshtm_report_Messages.aspx? StartNumber=2498&FocusIndex=All_100" 位址會換!
With ActiveSheet.QueryTables.Add(Connection:=webURL, Destination:=Range("A1"))
.PreserveFormatting = True
.RefreshStyle = xlInsertDeleteCells
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
End With
中間有行註解就是第一次改版的見證....''(改網址)
而這次改版後 本來使用 http://bsr.twse.com.tw/bshtm/bsC ... ;FocusIndex=All_100
就可以適用每支股票 只要改代碼就好
但是現在要指定頁數
比如3008的資料共20頁 http://bsr.twse.com.tw/bshtm/bsC ... p;FocusIndex=All_20
則ALL後面輸入1~20都抓得到 超過20則無法讀取
不知道能不能找出網站決定頁數的方法呢?
又 我在網站原始碼 view-source:http://bsr.twse.com.tw/bshtm/bsMenu.aspx 中發現
// window.open("bshtm/"+ HiddenField_spDate +"/"+ document.getElementById("hidTASKNO").value+"/"+ document.getElementById("hidTASKNO").value+".csv");
window.open("bsContent.aspx?StartNumber=" + document.getElementById("hidTASKNO").value + "&download=csv");
表示有csv檔作為網頁資料源?有沒有辦法抓到呢?
感覺會是比較一勞永逸的做法 且下載csv會比查詢快很多
感激不盡!
問題已解決! 順便修了一下原本貼的程式碼 把太亂無關的部分刪掉方便大家看@@ |
|