ªð¦^¦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!!

¥»©«³Ì«á¥Ñ Hsieh ©ó 2012-3-2 09:46 ½s¿è

¦^´_ 1# chen_cook

    With CreateObject("InternetExplorer.Application")
        .Visible = True
        .Navigate URL
        Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
        For Each n In .Document.getelementsbytagname("INPUT") '³o­Ó°j°é§ä¨ì«ö¶s¬O²Ä´X­Ó¿é¤J¶µ
           kn = n.Value
           If kn = "¬d¸ß" Then Exit For
           s = s + 1
        Next
        .Document.all("input_stock_code").Value = 6121 '­n¬dªº¥N½X
        .Document.getelementsbytagname("INPUT")(s).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??79´Nªí¥Ü²Ä80­Óªí®æ
¦¹ºô­¶Â^¨ú½Ð´ú¸Õ
  1. Sub Macro1()
  2.     Dim i As Integer, j As Integer, k As Integer
  3. URL$ = "http://www.gretai.org.tw/ch/stock/statistics/monthly/st42.php"
  4.     With CreateObject("InternetExplorer.Application")
  5.         .Visible = True
  6.         .Navigate URL
  7.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  8.         For Each n In .Document.getelementsbytagname("INPUT") '³o­Ó°j°é§ä¨ì«ö¶s¬O²Ä´X­Ó¿é¤J¶µ
  9.            kn = n.Value
  10.            If kn = "¬d¸ß" Then Exit For
  11.            s = s + 1
  12.         Next
  13.         .Document.all("input_stock_code").Value = 6121 '­n¬dªº¥N½X
  14.         .Document.getelementsbytagname("INPUT")(s).Click    '«ö¤U¬d¸ß¯Ã
  15.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  16.         Application.Wait Now + TimeValue("00:00:02") 'µ¥«Ý2¬í§ó·s¸ê®Æ
  17.         Set tmp = .Document.all("rpt_result").getelementsbytagname("table")(2) 'Åã¥Ü°Ï²Ä3­Óªí®æ
  18.         k = 1
  19.         Cells(k, 1) = tmp.Rows(0).innertext
  20.         Cells(k, 1).WrapText = False
  21.         For i = 1 To tmp.Rows.Length - 1
  22.             k = k + 1
  23.             For j = 0 To tmp.Rows(i).all.Length - 1
  24.                 Cells(k, j + 1) = tmp.Rows(i).Cells(j).innertext
  25.             Next
  26.         Next
  27.         k = k + 1
  28.         Set tmp = .Document.all("rpt_result").getelementsbytagname("table")(3) 'Åã¥Ü°Ï²Ä4­Óªí®æ
  29.         For i = 0 To tmp.Rows.Length - 1
  30.             k = k + 1
  31.             For j = 0 To tmp.Rows(i).all.Length - 1
  32.                 Cells(k, j + 1) = tmp.Rows(i).Cells(j).innertext
  33.             Next
  34.             Next
  35.             .Quit
  36.         End With
  37. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

·PÁ Hsieh ¤j¤j ¨ó§U¸Ñ¨M,ªì¨B´ú¸Õ§ì¨ì¤F..

          kn = n.Value    <==¦A½Ð±Ð³o¦æ¬O¦ó·N,VBA «O¯d¦r¶Ü??
         ¨ä¥¦¤j·§¬ÝªºÀ´.....

TOP

¦^´_ 3# chen_cook

°£¤FVALUE¬OÄÝ©Ê¥~
    kn¡Bn¨Ã«D«O¯d¦r¡A³o¬OÅܼơA§A¦Û¤v¥i¥H³]¸m¥ô¦ó¦³·N¸qªº¦r¦ê¨ú¥N
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

½Ð°Ý¤j¤j, ¦p­n¬d¨ä¥LªÑ²¼,À³¦p¦ó­×§ï.TKS¡I¡I

TOP

¦^´_ 5# tsuneng


    .Document.all("input_stock_code").Value = 6121  <--- stockscode$
     cells(1, 1) = stockcode$

TOP

¦^´_ 6# chen_cook

·PÁ chen_cook ¤j¤j¦^µª, ¦]¬OVBA·s¤â¦b¨Ï¥Î¤W¦³³\¦h¤£©ú¥Õ¦a¤è, ¦p¤è«K¸Ü¥i§_¤ñ·Ó1#,2# ªº¨Ò¤l.±NCODE ¶K¤W°Ñ¦Ò. TKS!!!

TOP

¦pªG§A¤£·Q©Î¤£·|¼gVBA¡A¥i¥H°Ñ¦Ò³o­ÓÀÉ®×
¤@§Z¤T¥|¡BÅå¨ìåF¥N»x

TOP

¦^´_ 7# tsuneng


    µª®×³£¤w¦^µª¤F!!¦pªGÁÙ¬O·Q¤£³Ò¦ÓÀò,¨º´N¦³¤T½u¤F.:Q

TOP

ÁÂÁ¦^µª,§Ú¤£¬O·Q"¤£³Ò¦ÓÀò"¦Ó¬O¯uªº¤£·|,¯uªº·Q¾Ç,¤~·|¦b³o´£¥X°ÝÃD¡C(¦p¤j¤j¤]¬O4¦~¯Å¸Ü¡AÀ³¸Ó·|Åé½Ì§Ú­Ì³o¤@¶¥¬qªº¤H,¦b¹q¸£ªºª¾ÃѬO¦³³\¦h¤£¨¬¤§³B)...  ¦A¦¸ÁÂÁ¤j¤j¦^µª.

TOP

        ÀR«ä¦Û¦b : ®É®É¦n¤ß´N¬O®É®É¦n¤é¡C
ªð¦^¦Cªí ¤W¤@¥DÃD