ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ²{¦b­n¦p¦ó¨ìÃÒ¥æ©Ò¤U¸ü¥~¸ê¦¨¥æ¸ê°T

[µo°Ý] ²{¦b­n¦p¦ó¨ìÃÒ¥æ©Ò¤U¸ü¥~¸ê¦¨¥æ¸ê°T

¤§«e¬O¥Î¤U¦Cªºµ{¦¡½X ¨ì http://www.twse.com.tw/ch/trading/fund/TWT38U/TWT38U.php ³oÃä¥h¤U¸ü¨C¤é¥~¸ê¶R½æ¶W¸ê°T¡C
­ì¥»³£¨S¦³°ÝÃD¡A¦ý¤@¤ë¥÷ ÃÒ¥æ©Ò§ïºô­¶¡A­ì¥»¥i¥H¬Ý¨ì¤@­Ó¤U¸ü¸ô®|¡A¦ý²{¦b¨S¿ìªk¬Ý¨ì¡A¾É­P¤£ª¾¹D¸Ó¦p¦ó¤U¸ü¨C¤éªº CSV ÀÉ...

¦³¨S¦³¤Hª¾¹D¸Ó¦p¦ó¤U¸ü¡H

Dim st
Dim myURL As String
Dim oStream As Object           'ADODB.Stream
Dim WinHttpReq As Object            'XMLHTTP
Dim fileidx As String
Dim seldate As String

Worksheets("Config").Select
endline = Range("A65536").End(xlUp).Row


    seldate = Range("A" & i).Value    ''¦¨¥æ¤é´Á
    fileidx = seldate
   
    ''http://www.twse.com.tw/ch/trading/fund/TWT38U/TWT38U_print.php?edition=ch&filename=genpage/A20141202.dat&type=csv
   
    myURL = "http://www.twse.com.tw/ch/trading/fund/TWT38U/TWT38U_print.php?edition=ch&filename=genpage/A" & _
            fileidx & ".dat&type=csv"
         
    ''¥~¸ê¶R½æ¸ê°T
    Set WinHttpReq = CreateObject("MSXML2.XMLHTTP")
    With WinHttpReq
        .Open "GET", myURL, False
        .Send
        myURL = .responseText
    End With
    Set oStream = CreateObject("ADODB.Stream")
    With oStream
        .Open
        .Type = 1
        .Write WinHttpReq.responseBody
        fileidx = Sheets("Config").Range("G2") & "\A" & fileidx & ".csv"          ''³]©w¤U¸ü¸ô®|¤ÎÀɦW
        On Error Resume Next
        Kill fileidx
        On Error GoTo 0
        .SaveToFile fileidx
        .Close
    End With
    Set WinHttpReq = Nothing
    Set oStream = Nothing

End Sub

·PÁÂstillfish00©MGBKEE¨â¦ì¤j¤jªºµªÂÐ
§Ú¬ã¨s¬Ý¬Ý
ÁÂÁÂ

TOP

¦^´_ 10# go2hk

¥i°Ñ¦Ò³o¸Ì
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 10# go2hk
·íµM¤£¬OÀH«K®M¥Î....
ºô­¶¤d¦ÊºØ¡A¤W­±¤èªk¬O¦b§A¯àª¾¹D¦b¤U¸üÀÉ®×®É
¥¦©Òµo¥X½Ð¨Dªº¹ï¶Hºô­¶©MPost ©ÎGet°Ñ¼Æ®É¤~¥Îªº....

¦Ü©ó«ç»ò¤ÀªR¥X¤U¸ü½Ð¨Dªº¹ï¶Hºô­¶©MPost ©ÎGet°Ñ¼Æ¡A
¨º¬O¥t¤@¦^¨Æ¡A§Ú¤]¨Ã«D³£¤F¸Ñ....

³£¤£ª¾¹Dªº¸Ü´N¾ÇµÛ¥Î IEª«¥ó(InternetExplorer.Application)ªº¤èªk§a¡A¤ñ¸û¦n¤Jªù...

ex:
1.   Âd¶R¤¤¤ß¤T¤jªk¤H¶R½æ©ú²Ó¸ê°T
¥ÎGET¤èªk
¤U¸üºô§}   http://www.tpex.org.tw/web/stock ... _hedge_download.php
GET°Ñ¼Æ    l=zh-tw&t=D&d=104/03/24&s=0,asc,0

2Ãi±o§ä¤F..
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

ÁÂÁÂstillfish00¤j¤jªºµ{¦¡½X
¶¶§Q¤U¸üÃÒ¥æ©Òªº¥~¸ê¶R½æ¶W¸ê°T
¥t¥~¤]¦Û¦æ§ï¦¨¤U¸ü§ë«H¶R½æ¶W¸ê°T
³£¯à¥¿±`¨Ï¥Î«D±`·PÁÂ

¦ý¬O·Q¥t¥~½Ð°Ý
¥H¤U¨â­Óºô­¶¬OÂd¶R¤¤¤ßªººô­¶
1.¤T¤jªk¤H¶R½æ©ú²Ó¸ê°T :
http://www.tpex.org.tw/web/stock/3insti/daily_trade/3itrade_hedge.php?l=zh-tw
2.¤WÂdªÑ²¼¨C¤é¦¬½L¦æ±¡(¤£§t©w»ù)
§Ú»Ý­nªº¬O©Ò¦³ÃÒ¨é(¤£§tÅvÃÒ.¤ûºµÃÒ)
http://www.tpex.org.tw/web/stock/aftertrading/otc_quotes_no1430/stk_wn1430.php?l=zh-tw

§Ú¦Û¦æ­×§ï¤Fºô§}ªº³¡¤À
µ²ªG§ì¦^¨ÓªºcsvÀÉ
¤º®e«o¬Oºô­¶ªº­ì©l½X
½Ð°Ý¬O¤£¬O¤U¦C³o¬q»Ý­n°µ¦ó½Õ¾ã

Set WinHttpReq = CreateObject("MSXML2.XMLHTTP")
    With WinHttpReq
        .Open "POST", myURL, False
        .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        .setRequestHeader "Content-Length", Len(sPost)
        .send (sPost)
    End With

©Î¬O¸Ó¦p¦ó½Õ¾ã
¨Ï±o¯à°÷¤U¸ü¦^csvÀÉ
·PÁÂ

TOP

¦^´_ 8# adranimal
¤@¤G¼Ó³£¦³½u¯Á¡A¦Û¤v°µ°µ¬Ý
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 7# stillfish00
·PÁÂS¤jªº«ü±Ð
¤w¸g¥i¥H¨Ï¥Î¤F
¦ý¬O¦pªG§Ú·Q­nÅý§ìÀɪº¤é´Áµ¥©óSheets("UI").Range("A22").Value À³¸Ó«ç»ò½s¼g©O?

TOP

¦^´_ 6# adranimal
¥J²ÓÂI°Ú¡A§A.WebTables Äݩʧï¤F¨â¦¸
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

·PÁÂS¤j¦^ÂÐ
¥Ø«e§ï¦¨³o¼Ë
Sub getSIIPrice()

    urlStr = "URL;http://www.twse.com.tw/ch/trading/exchange/MI_INDEX/MI_INDEX.php"
    Sheets("SIIPrice").Select
    Cells.Select
    Selection.Delete Shift:=xlUp
  With ActiveSheet.QueryTables.Add(Connection:= _
    urlStr _
     , Destination:=Range("A1"))
      .WebTables = "2"
      .PostText = "downlod=&qdate=104%2F03%2F12&selectType=ALLBUT0999"
      .Name = "19"
      .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 = "10"
      .WebPreFormattedTextToColumns = True
      .WebConsecutiveDelimitersAsOne = True
      .WebSingleBlockTextImport = False
      .WebDisableDateRecognition = False
      .WebDisableRedirections = False
      .Refresh BackgroundQuery:=False
      .Delete
   End With
End Sub

¦ý¬O¨S¦³¦^¶Ç¸ê®Æ¡A¤£ª¾°ÝÃD¥X¦b­þ?

TOP

¦^´_ 4# adranimal
urlstr = "URL;http://www.twse.com.tw/ch/trading/exchange/MI_INDEX/MI_INDEX.php"
.WebTables = "2"
.PostText = "download=&qdate=104%2F03%2F12&selectType=ALLBUT0999"

§ï³o¤T­Ó¦a¤è
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

        ÀR«ä¦Û¦b : ¨C¤ÑµL©Ò¨Æ¨Æ¡A¬O¤H¥Íªº®ø¶OªÌ¡A¿n·¥¡B¦³¥Î¤~¬O¤H¥Íªº³Ð³yªÌ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD