標題:
[發問]
請教如何查詢個股月營收資料
[打印本頁]
作者:
leondavinci727
時間:
2015-9-7 14:14
標題:
請教web查詢 沒有傳回資料的問題
請問這3個網址無法使用web查詢,要嘛就是顯示"伺服器忙碌中, 請稍後再查詢..."不然就是"沒有傳回資料"
可是不久前我使用開啟檔案自動更新都還可以,請問有別的方法可以一樣下載資料並在開啟檔案時自動更新嗎?
http://goodinfo.tw/StockInfo/StockIdxDetail.asp?STOCK_ID=%E5%8A%A0%E6%AC%8A%E6%8C%87%E6%95%B8
http://goodinfo.tw/StockInfo/ShowBuySaleChart.asp?STOCK_ID=%E5%8A%A0%E6%AC%8A%E6%8C%87%E6%95%B8&CHT_CAT=DATE
http://goodinfo.tw/StockInfo/ShowBearishChart.asp?STOCK_ID=%E5%8A%A0%E6%AC%8A%E6%8C%87%E6%95%B8&CHT_CAT=DATE
作者:
GBKEE
時間:
2015-9-11 11:08
回復
1#
leondavinci727
這網頁無法用web查詢.
試試看
Option Explicit
'加權指數 法人買賣超日統計圖- Goodinfo!台灣股市資訊網
Const 法人買賣 = "http://goodinfo.tw/StockInfo/ShowBuySaleChart.asp?STOCK_ID=%E5%8A%A0%E6%AC%8A%E6%8C%87%E6%95%B8&CHT_CAT=DATE"
'加權指數 融資融券餘額日統計圖 - Goodinfo!台灣股市資訊網
Const 融資融券 = "http://goodinfo.tw/StockInfo/ShowBearishChart.asp?STOCK_ID=%E5%8A%A0%E6%AC%8A%E6%8C%87%E6%95%B8&CHT_CAT=DATE"
Sub Ex_台灣股市資訊網()
Dim i As Integer, b As Object, E As Object, R As Integer, Ar, A As Variant
Dim ie, Ay(), k As Integer
Ay = Array(法人買賣, 融資融券)
'Set ie = CreateObject("InternetExplorer.Application")
With CreateObject("InternetExplorer.Application")
.Visible = True
For k = 1 To 2
.Navigate Ay(k - 1)
Do While .Busy Or .readyState <> 4: DoEvents: Loop
Do
Set E = .Document.getElementsByTagName("table")
Loop While E Is Nothing
With Sheets(k)
.Cells.Clear
R = 1
'Ar = Array(18, 21, 23, 30) '法人買賣 30,融資融券 29
Ar = Array(18, 21, 23, IIf(k = 1, 30, 29))
For Each A In Ar
For Each b In E(A).Rows
For i = 0 To b.Cells.Length - 1
.Cells(R, i + 1) = b.Cells(i).innertext
Next
R = R + 1
Next
R = R + 1
Next
End With
Next
.Quit '關閉網頁
End With
End Sub
複製代碼
作者:
jack200217
時間:
2015-9-17 20:31
標題:
請教如何查詢個股月營收資料
請問下面網址無法使用web查詢,如何透過VBA更改股號抓取月營收表格資料
再煩請協助幫忙!!謝謝!!
http://goodinfo.tw/StockInfo/ShowSaleMonChart.asp?STOCK_ID=
3481
作者:
GBKEE
時間:
2015-9-18 07:42
回復
3#
jack200217
更新上面的程式碼
Option Explicit
Const 個股月營收 = "http://goodinfo.tw/StockInfo/ShowSaleMonChart.asp?STOCK_ID="
'加權指數 法人買賣超日統計圖
Const 法人買賣 = "http://goodinfo.tw/StockInfo/ShowBuySaleChart.asp?CHT_CAT=DATE&STOCK_ID="
'加權指數 融資融券餘額日統計圖
Const 融資融券 = "http://goodinfo.tw/StockInfo/ShowBearishChart.asp?CHT_CAT=DATE&STOCK_ID="
Sub Ex() 'Goodinfo!台灣股市資訊網
Dim i As Integer, b As Object, E As Object, R As Integer, Ar, A As Variant
Dim ie, Ay(), k As Integer, STOCK_ID As String, Msg As Boolean
Do
STOCK_ID = InputBox("輸入個股 代號", "個股 代號", 3481)
Loop Until Val(STOCK_ID) And Len(STOCK_ID) >= 4
Ay = Array(個股月營收 & STOCK_ID, 法人買賣 & STOCK_ID, 融資融券 & STOCK_ID)
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
For k = 1 To 3
.Navigate Ay(k - 1)
Do While .Busy Or .readyState <> 4: DoEvents: Loop
With .Document.BODY
If InStr(.INNERTEXT, "查無") Then
Msg = True
GoTo Er
End If
End With
Do
Set E = .Document.getElementsByTagName("table")
Loop While E Is Nothing
If Sheets.Count < k Then Sheets.Add after:=Sheets(Sheets.Count)
With Sheets(k)
.Cells.Clear
R = 1
If k = 1 Then '個股月營收
Ar = Array(13, 20)
ElseIf k = 2 Then '法人買賣
Ar = Array(19, 22, 24, 31)
Else '融資融券
Ar = Array(19, 22, 24, 30)
End If
For Each A In Ar
For Each b In E(A).Rows
For i = 0 To b.Cells.Length - 1
' If InStr(b.Cells(i).INNERTEXT, "資料日期: 無交易資料") Then
' Msg = True
' GoTo Er
' End If
.Cells(R, i + 1) = b.Cells(i).INNERTEXT
Next
R = R + 1
Next
R = R + 1
Next
End With
Next
Er: ' Title
MsgBox Split(.Document.Title, "-")(0) & IIf(Msg, "查無相關資料", " 下載 ok")
.Quit '關閉網頁
End With
End Sub
複製代碼
作者:
jack200217
時間:
2015-9-21 13:38
回復
4#
GBKEE
了解了,下次會再多加注意!
謝謝版主用心!
作者:
kelvnelau1213
時間:
2015-10-14 09:44
回復
4#
GBKEE
請問版本,您在抓goodinfo的表格時,會常碰到「伺服器忙碌中, 請稍後再查詢...」的狀況嗎?
有沒有其他的方式可以避開
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)