透過Excel VBA撈取上市公司公佈的每月營收資料。

詳細請參考:VBA教學,撰寫的十分清楚~

 


 

 

公開資訊觀測站 http://mops.twse.com.tw/t21/sii/t21sc03_103_2_0.html
VBA教學 http://white5168.blogspot.tw/2012/08/excel-vba.html
用python抓網頁data http://ithelp.ithome.com.tw/question/10127973

 


Excel2003 :

VBA操作:工具 > 巨集 > VB編輯器

在按鈕的程式碼中,這段需要自行更改,因為後續財報有區分IFRS,所以URL的部份有更改。

weburl = "http://mops.twse.com.tw/t21/" & xlKind & "/t21sc03_" & xlYear & "_" & xlMonth & "_0.html"
     
     


 

20150527;

有人詢問網址變動要怎麼查詢?

 

1.開啟公開資訊觀測站網頁

http://mops.twse.com.tw/mops/web/index

 

2.選擇相對應的網頁

Snap2  

 

3.取得[公司104年4月份(累計與當月)營業收入統計表]

http://mops.twse.com.tw/nas/t21/sii/t21sc03_104_4_0.html

 

4.根據該網址規則,去更改Excel的VBA程式碼即可

可以發現這次網址多出了【/nas】該目錄,所以造成以前的語法抓不到資料。

weburl = "http://mops.twse.com.tw/nas/t21/" & xlKind & "/t21sc03_" & xlYear & "_" & xlMonth & "_0.html"

arrow
arrow
    全站熱搜

    Nathan 發表在 痞客邦 留言(9) 人氣()