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

[µo°Ý]VBA§ì¨ú.PHP­¶°ÝÃD??

[µo°Ý]VBA§ì¨ú.PHP­¶°ÝÃD??

¦U¦ì¥ý¶i
              ¤£¤~¦bºô¸ô¤W¬Ý¨ì¤@¬q§ì¨úÂd¶R.phpªº¸ê®Æ,­ì¤å¦p¤U
   
Sub Macro1()
    Dim i As Integer, j As Integer, k As Integer
URL$ = "http://www.gretai.org.tw/ch/stock/statistics/monthly/st42.php"
    With CreateObject("InternetExplorer.Application")
        .Visible = True
        .Navigate URL
        Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
        .Document.all("input_stock_code").Value = 6121 '­n¬dªº¥N½X
        .Document.all(1758).Click    <=====¥¨¶°°õ¦æ¨ì¦¹´N¿ù»~,½Ð°Ý³o¤@¦æ¬O¬°¦ó·N,§ä¤F«Ü¤[¬d¤£¥X¬O¦ó·N
        Application.Wait Now + TimeValue("00:00:02") 'µ¥«Ý2¬í§ó·s¸ê®Æ
        Set tmp = .Document.getelementsbytagname("table")(79) <==== (79)¤S¬O¦ó·N??
        k = 1
        Cells(k, 1) = tmp.Rows(0).innertext
        Cells(k, 1).WrapText = False
        For i = 1 To tmp.Rows.Length - 1
            k = k + 1
            For j = 0 To tmp.Rows(i).all.Length - 1
                Cells(k, j + 1) = tmp.Rows(i).Cells(j).innertext
            Next
        Next
        k = k + 1
        Set tmp = .Document.getelementsbytagname("table")(82)<==== (82)¤S¬O¦ó·N??
        For i = 0 To tmp.Rows.Length - 1
            k = k + 1
            For j = 0 To tmp.Rows(i).all.Length - 1
                Cells(k, j + 1) = tmp.Rows(i).Cells(j).innertext
            Next
       ¦]­ìºô­¶´N¦b¿é¤J 6121 ´N°±¦í¤F,¥¼¯àIJµoºô­¶±a¥X¸ê®Æ,¬G«áÄòªº table ´NµLªk§ì¥X¼Æ¾Ú±a¤Jexecl,½Ð°Ý¥ý¶i»Ý¦p¦ó­×§ï¤~¦n..TKS!!

heavenweaver±z¦n¡A

¨Ï¥ÎFiddler¤u¨ãµo²{ºô§}¦³²§°Ê¡A¤w§ä¨ì°ÝÃD¤F¡AÁÂÁ±z

TOP

heavenweaver±z¦n¡A

·Q¦V±z½Ð±Ð¡A¥ý«eª©¥»¨Ì·Ó±zªº«ü¾É¤w¥i¥¿±`¨Ï¥Î¡A¦ý¤µ¤é¾Þ§@®É¡Aµo²{excel¸ê®Æ¸ü¤£¤U¨Ó¡A¬O§_¬ÛÃö°Ñ¼Æ­n­×§ï©O? ÁÂÁ±z¡C
  1. Private Sub CommandButton4_Click()

  2. '«Å§iÅܼÆ
  3.    Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
  4.    Dim TMP As Workbook


  5. '²M°£Â¸ê®Æ
  6.    Range("F66:Z200").Select
  7.    Selection.Clear

  8.    code = Range("A1").Value  'ªÑ²¼¥N½X
  9.    yy = Range("H4").Value '¦~«×


  10. '±N¸ê®Æ¥ý¦s¦ÜcÁV
  11.    With WinHttpReq
  12.    .Open "POST", "http://www.gretai.org.tw/ch/stock/statistics/monthly/download_st44.php", False
  13.    .Open "POST", Range("I4").Value, False
  14.    .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  15.    .Send "stk_no=" & code & "&yy=" & yy  '¶ÇªÑ²¼¥N½X¡B¦~«×°Ñ¼Æ
  16.           Set oStream = CreateObject("ADODB.Stream")
  17.           oStream.Open
  18.           oStream.Type = 1
  19.           oStream.Write WinHttpReq.ResponseBody
  20.           oStream.SaveToFile ("C:\" & code & "-M.csv")
  21.           oStream.Close
  22.    End With
  23.    

  24. End Sub
  25.    
½Æ»s¥N½X

TOP

¦^´_ 22# gto1208
°ÝÃD¦b³o¸Ì
'±N¸ê®Æ¥ý¦s¦ÜcÁV
    With WinHttpReq
    '.Open "POST", "http://www.gretai.org.tw/ch/stock/statistics/monthly/download_st44.php", False
  ±z±N³o¬q«ü¥OÅܦ¨remark¡A¥¿½T¦p¤U¡G
   .Open "POST", "http://www.gretai.org.tw/ch/stock/statistics/monthly/download_st44.php", False
«Ü©êºp¡A§Ú¬O¤p¾Ç¥Í¡A¤£¯à¤U¸üÀɮסA¬O­Ó¤p§¾«Ä¡I

TOP

¦^´_ 22# gto1208
½Ð°Ñ¦Ò¦Û¦æ­×§ï¡C
  1. Sub Macro1()
  2. '
  3. ' Macro1 Macro
  4. ' Lu ¦b 2003/2/28 ¿ý»sªº¥¨¶°
  5. '
  6. ' §Ö³tÁä: Ctrl+a
  7. '
  8. Dim yy, stock

  9. yy = Application.InputBox(prompt:="½Ð¿é¤J¬d¸ß¦~¥÷(¦p2013)¡G", Title:="¤WÂd²Î­p³øªí > ­ÓªÑ¤ë¦¨¥æ¸ê°T")
  10. stock = Application.InputBox(prompt:="½Ð¿é¤JªÑ²¼¥N½X(¦p3260)¡G", Title:="¤WÂd²Î­p³øªí > ­ÓªÑ¤ë¦¨¥æ¸ê°T")

  11. If yy = "" Then yy = "2013"
  12. If stock = "" Then stock = "3260"

  13. fileIdx = "C:\MyStock\Test\st44_" & stock & ".csv"

  14. myURL = "http://www.gretai.org.tw/ch/stock/statistics/monthly/download_st44.php"
  15. myPar = "yy=" & yy & "&stk_no=" & stock

  16. Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")

  17. With WinHttpReq
  18.     .Open "POST", myURL, False
  19.     .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  20.     .Send myPar
  21.     myURL = .ResponseBody
  22.     Set oStream = CreateObject("ADODB.Stream")
  23.     oStream.Open
  24.     oStream.Type = 1
  25.     If WinHttpReq.ResponseText = "" Then Exit Sub
  26.     oStream.Write WinHttpReq.ResponseBody
  27.     On Error Resume Next
  28.     Kill fileIdx
  29.     On Error GoTo 0
  30.     oStream.SaveToFile fileIdx
  31.     oStream.Close
  32. End With

  33. End Sub
½Æ»s¥N½X
«Ü©êºp¡A§Ú¬O¤p¾Ç¥Í¡A¤£¯à¤U¸üÀɮסA¬O­Ó¤p§¾«Ä¡I

TOP

heavenweaver±z¦n¡A

§Ú¤w¦³½Æ»s#12ªºSub WrittenByLalalada()¨Ó­×§ï
http://www.gretai.org.tw/ch/stock/statstics/monthly/download_st44.php
¤W¦Cºô§}¦³¤G­Ó°Ñ¼Æ¡A¤w±Nµ{¦¡§ï¼g¦p¤U¡A¦ý¦~«×ªºsend±ø¥óÁÙ¬O§ì¨ú¤£¨ì(µ{¦¡½X¦p¤U)¡AÁÂÁ±z
  1. Private Sub CommandButton1_Click()

  2. '«Å§iÅܼÆ
  3. Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
  4. Dim TMP As Workbook

  5. '²M°£Â¸ê®Æ
  6. Range("A4:Z2000").Select
  7. Selection.Clear

  8. code = Range("A1").Value  'ªÑ²¼¥N½X
  9. yy = Range("B1").Value  '¦~«×

  10.     '±N¸ê®Æ¥ý¦s¦ÜcÁV
  11.     With WinHttpReq
  12.     '.Open "POST", "http://www.gretai.org.tw/ch/stock/statistics/monthly/download_st44.php", False
  13.     .Open "POST", Range("C1").Value, False
  14.     .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  15.     .Send ("stk_no=" & code & "yy=" & yy)
  16.            Set oStream = CreateObject("ADODB.Stream")
  17.            oStream.Open
  18.            oStream.Type = 1
  19.            oStream.Write WinHttpReq.ResponseBody
  20.            oStream.SaveToFile ("C:\" & code & ".csv")
  21.            oStream.Close
  22.     End With
  23. End Sub
½Æ»s¥N½X

TOP

¦^´_ 19# gto1208
¦pªG±z¬O°Ý#12ªºSub WrittenByLalalada()¡Aª½±µ½Æ»s¨ì±zªº¥¨¶°¥h°õ¦æ¡A´N·|¸õ¥X¤@­Óµøµ¡¸ß°Ý¬d¸ßªÑ²¼¥N¸¹¡Aª½±µ¿é¤J´N¦n¤F¡C
«Ü©êºp¡A§Ú¬O¤p¾Ç¥Í¡A¤£¯à¤U¸üÀɮסA¬O­Ó¤p§¾«Ä¡I

TOP

¦^´_ 12# lalalada


·PÁ±z´£¨Ñªºvba code¡A¸g´ú¸Õ§¹¥þ¥¿±`¤S¤£»Ý­n¶}±ÒIEºô­¶¡A­È±oÆ[¼¯¾Ç²ß¡I
«Ü©êºp¡A§Ú¬O¤p¾Ç¥Í¡A¤£¯à¤U¸üÀɮסA¬O­Ó¤p§¾«Ä¡I

TOP

¦U¦ì°ª¤â±z¦n
http://www.gretai.org.tw/ch/stock/statistics/monthly/st44.php
»P¤W­zºô¯¸¬ÛÃþ¡A¦ý¥¦¿é¤J®É¦³¤G­Ó°Ñ¼Æ¡A¥Ø«e§ä¨ìªº°Ñ¼Æ¬O"yy"¡A·Q½Ð±Ð¤@¤U¦pªG¬O¦³stk_no»Pyy¡A¤U­±sendªºµ{¦¡¸Ó¦p¦ó­×§ï©O? ÁÂÁÂ
.Send ("stk_no=" & code)

TOP

ÁA¸Ñ¤F!!!
«D±`ÁÂÁÂK¤jªº¹Ï¤å¸Ñ»¡~
³sdata code ³£¸Ñ»¡¤F~¯uªº«D±`²M·¡!!
Nicole

TOP

        ÀR«ä¦Û¦b : ¯u¥¿ªº·R¤ß¡A¬O·ÓÅU¦n¦Û¤vªº³oÁû¤ß¡C
ªð¦^¦Cªí ¤W¤@¥DÃD