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

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

¦^´_ 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

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

¦^´_ 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

¦^´_ 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

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

heavenweaver±z¦n¡A

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

TOP

        ÀR«ä¦Û¦b : ª¾ÃÑ­n¥Î¤ßÅé·|¡A¤~¯àÅܦ¨¦Û¤vªº´¼¼z¡C
ªð¦^¦Cªí ¤W¤@¥DÃD