Board logo

標題: [發問] 請問鉅亨網如何編寫抓取我要的日期股價資料 [打印本頁]

作者: ch0726    時間: 2015-8-29 02:35     標題: 請問鉅亨網如何編寫抓取我要的日期股價資料

我是將web資料存成.iqy,再用記事本修改,可以成功自動抓取資料,但日期設定我不會,希望有會的人能教我,我想改抓一至二年的股價資料。
編碼如下
WEB
1
http://www.cnyes.com/twstock/ps_historyprice/[ "A","code" ].htm

Selection=2
Formatting=None
PreFormattedTextToColumns=True
ConsecutiveDelimitersAsOne=True
SingleBlockTextImport=False
DisableDateRecognition=False
DisableRedirections=False[attach]21860[/attach]
作者: Scott090    時間: 2017-10-15 07:16

回復 1# ch0726

我也在尋求這個答案:
    http://forum.twbts.com/thread-20190-1-1.html

假如有解請分享
作者: rogersg    時間: 2018-1-6 22:18

隨便寫寫,參考看看

Sub 巨集1()
'
' 巨集1 巨集
'

'
Dim S As String
Dim E As String
Dim B As String
Dim P As String

S = "ctl00$ContentPlaceHolder1$startText="
E = "ctl00$ContentPlaceHolder1$endText="
B = "ctl00$ContentPlaceHolder1$submitBut=""查詢"""
P = Format(InputBox("請輸入起始日期", "參數輸入", Date), "YYYY/MM/DD")
S = S + P
P = ""
P = Format(InputBox("請輸入結束日期", "參數輸入", Date), "YYYY/MM/DD")
E = E + P
    Application.CutCopyMode = False
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;https://www.cnyes.com/twstock/ps_historyprice.aspx?pageTypeHidden=1 & code=2330" & S & E & B, _
        Destination:=Range("$A$1"))
'        .CommandType = 0
        .Name = "ps_historyprice.aspx?code=2330"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "1"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
End Sub




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)