- 帖子
- 2
- 主題
- 1
- 精華
- 0
- 積分
- 1
- 點名
- 0
- 作業系統
- Windows
- 軟體版本
- 7
- 閱讀權限
- 10
- 註冊時間
- 2014-11-20
- 最後登錄
- 2014-12-8
|
本帖最後由 GBKEE 於 2014-11-21 17:14 編輯
GBKEE大大,之前有看您幫助解決在公開資訊觀測站抓資料的文
我需要抓取公司的財務資料(網址如下)
http://mops.twse.com.tw/mops/web/t164sb04
透過GBKEE大大的指導,我可以用VBA Excel抓到非金融公司的資料(程式碼如下)
Dim Ie, Doc As Object, i, j As Long
Set Ie = CreateObject("InternetExplorer.Application")
With Ie
Ie.Navigate "http://mops.twse.com.tw/mops/web/t164sb04"
Ie.Visible = True
Do While Ie.Busy Or Ie.ReadyState <> 4: DoEvents: Loop
.Document.getelementbyID("isnew").Value = "true" '最新資料 = true, 歷史資料 = false
.Document.getelementbyID("co_id").Value = "2888" '股票代號
.Document.getelementbyID("year").Value = Year '年度
.Document.getelementbyID("season").Value = Quarter '第一季 = 01, 第二季 = 02, 第三季 = 03, 第四季 = 04
For i = 0 To .Document.getElementsByTagName("input").Length - 1
If .Document.getElementsByTagName("input")(i).Type = "button" And .Document.getElementsByTagName("input")(i).Value = " 搜尋 " Then
.Document.getElementsByTagName("input")(i).Click
End If
Next
但碰到要下載金融公司的財報就卡住了,我不管怎試,就是進不到第2層(如下畫面)
上面的程式碼不會直接跑出財報,只會列出金融公司相關公司資訊。必須再次點選"詳細資料"才能叫出財報資料
[attach]19616[/attach]
不知道GBKEE大大能否幫忙看一下
感恩 |
|