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

[µo°Ý] ½Ð°Ý¦p¦ó®»¨úºô­¶­n¿é¤JªºTABLE¨ìªí®æ¡AÁÂÁÂ

[µo°Ý] ½Ð°Ý¦p¦ó®»¨úºô­¶­n¿é¤JªºTABLE¨ìªí®æ¡AÁÂÁÂ

°Ñ¦Òhttp://forum.twbts.com/viewthread.php?tid=9511
½Ð°Ý¨ºùØ¿ù¡A¦pªGDate­n¥Î NOW()¨ú1200¤Ñ¦p¦ó§ï¡AÁÂÁÂ
  1. Sub Ex()
  2.     Dim i As Integer, s As Integer, k As Integer, A, ii, j
  3.     Dim co_id As String, isnew As String, season As String
  4.                                     '²Ä¤@©u 01,²Ä¤G©u 02²Ä¤T©u 03,²Ä¥|©u 04.
  5.     With CreateObject("InternetExplorer.Application")
  6.         .Visible = True
  7.         .Navigate "https://www.cnyes.com/twstock/ps_historyprice/1216.htm"
  8.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  9.         With .document
  10.             For Each A In .getelementsbytagname("INPUT")
  11.                 If A.Name = "ctl00$ContentPlaceHolder1$startText" Then A.Value = "2016/06/01"
  12.             Next
  13.             For Each A In .getelementsbytagname("INPUT")
  14.                 If A.Name = "ctl00$ContentPlaceHolder1$endText" Then A.Value = "2019/07/27"
  15.             Next
  16.             For Each A In .getelementsbytagname("INPUT")
  17.                 If Trim(A.Value) = "¬d¸ß" And A.Name = "ctl00$ContentPlaceHolder1$submitBut" Then A.Click      '«ö¤U[¬d¸ß]Áä
  18.             Next
  19.             

  20.         End With
  21.         On Error Resume Next       '***¦³¨Çtable¨SRows¸ê®Æ·|²£¥Í¿ù»~ ¤£²z·|¥¦,µ{¦¡Ä~Äò¨«
  22.         Set A = .document.getelementsbytagname("table")(0).outerhtml
  23.         
  24.         With ActiveSheet
  25.             .Cells.Clear
  26.            '************************
  27.            ' For ii = 0 To A.Length - 1        '¤£ª¾¹Dtable½d³ò¦b¦ó³B: ±q0¶}©l
  28.            '******************************
  29.             For ii = 11 To A.Length - 1        ''±q11¶}©l ¥Î Debug.Print ii  §ä¥X©Ò­n¸ê®Æªºtable½d³ò
  30.                 For i = 0 To A(ii).Rows.Length - 1      '¼g¤J¸ê®Æ
  31.                 'Debug.Print ii  ¥i§ä¥X©Ò­n¸ê®Æªº table ½d³ò
  32.                 k = k + 1
  33.                 For j = 0 To 5
  34.                     Cells(k, j + 1) = A(ii).Rows(i).Cells(j).innerText
  35.                 Next
  36.             Next
  37.             Next
  38.    
  39.         End With
  40. '       .Quit        'Ãö³¬ºô­¶
  41.     End With
  42. End Sub
  43. 'vba ¾Þ§@ie¶×¤J¸ê®Æ 'http://forum.twbts.com/viewthread.php?tid=9511
  44. '¦p¦ó¦bºô­¶·j´Mµ²ªG«á¡A¦A«ö­­®É¶¡«ö¶s
  45. 'ºô­¶µn¤J-«ö¶s°ÝÃD


  46. '<div class="mbx bd3" enableviewstate="false">
  47. '<h3 class="tabName"><span id="ctl00_ContentPlaceHolder1_titleLab">²Î¤@ ¾ú¥v¦æ±¡</span></h3>
  48. '<div class="blank10" enableviewstate="false"></div>
  49. '<span class="srchyear2" >
  50. '¶}©l¤é´Á<input name="ctl00$ContentPlaceHolder1$startText" type="text" value="2016/06/01" maxlength="10" id="ctl00_ContentPlaceHolder1_startText" style="width:72px;" />
  51. 'µ²§ô¤é´Á<input name="ctl00$ContentPlaceHolder1$endText" type="text" value="2019/07/27" maxlength="10" id="ctl00_ContentPlaceHolder1_endText" style="width:72px;" />
  52. '<input type="submit" name="ctl00$ContentPlaceHolder1$submitBut" value="¬d¸ß" id="ctl00_ContentPlaceHolder1_submitBut" class="butn btnga" />
  53. '    <span style="float:right">
  54. '</span>
  55. '</span>
½Æ»s¥N½X

[ª©¥DºÞ²z¯d¨¥]
  • GBKEE(2020/4/25 16:12): http://forum.twbts.com/thread-22471-1-2.html °Ñ¦Ò¬Ý¬Ý

§ï³o¼Ë¥i¦æ¡A¦ý¬°¤°»ò²Ä¤G¦¸°õ¦æ·|¿ù»~
  1. Sub Ex()
  2.     Dim i As Integer, s As Integer, k As Integer, A, ii, j
  3.     Dim co_id As String, isnew As String, season As String
  4.                                     '²Ä¤@©u 01,²Ä¤G©u 02²Ä¤T©u 03,²Ä¥|©u 04.
  5.     With CreateObject("InternetExplorer.Application")
  6.         .Visible = True
  7.         .Navigate "https://www.cnyes.com/twstock/ps_historyprice/1216.htm"
  8.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  9.         With .document
  10.             For Each A In .getElementsByTagName("INPUT")
  11.                 If A.Name = "ctl00$ContentPlaceHolder1$startText" Then A.Value = Format(Now - 1500, "yyyy/mm/dd") '"2016/06/01"
  12.             Next
  13.             For Each A In .getElementsByTagName("INPUT")
  14.                 If A.Name = "ctl00$ContentPlaceHolder1$endText" Then A.Value = Format(Now, "yyyy/mm/dd") '"2019/07/27"
  15.             Next
  16.             For Each A In .getElementsByTagName("INPUT")
  17.                 If Trim(A.Value) = "¬d¸ß" And A.Name = "ctl00$ContentPlaceHolder1$submitBut" Then A.Click      '«ö¤U[¬d¸ß]Áä
  18.             Next


  19.         End With
  20.     '    On Error Resume Next       '***¦³¨Çtable¨SRows¸ê®Æ·|²£¥Í¿ù»~ ¤£²z·|¥¦,µ{¦¡Ä~Äò¨«
  21.       Do While .Busy Or .ReadyState <> 4: DoEvents: Loop

  22.       
  23.      Set A = .document.getElementsByTagName("table")(0)
  24. '    On Error Resume Next

  25.         With ActiveSheet
  26.                 .Cells.Clear

  27.             For i = 0 To A.Rows.Length - 1

  28.                 For j = 0 To A.Rows(i).Cells.Length - 1

  29.                     .Cells(i + 1, j + 1) = A.Rows(i).Cells(j).innerText
  30. Debug.Print i
  31.                 Next

  32.             Next

  33.         End With

  34.         .Quit        'Ãö³¬ºô­¶
  35.     End With
  36. End Sub
  37. 'vba ¾Þ§@ie¶×¤J¸ê®Æ 'http://forum.twbts.com/viewthread.php?tid=9511
  38. '¦p¦ó¦bºô­¶·j´Mµ²ªG«á¡A¦A«ö­­®É¶¡«ö¶s
  39. 'ºô­¶µn¤J-«ö¶s°ÝÃD


  40. '<div class="mbx bd3" enableviewstate="false">
  41. '<h3 class="tabName"><span id="ctl00_ContentPlaceHolder1_titleLab">²Î¤@ ¾ú¥v¦æ±¡</span></h3>
  42. '<div class="blank10" enableviewstate="false"></div>
  43. '<span class="srchyear2" >
  44. '¶}©l¤é´Á<input name="ctl00$ContentPlaceHolder1$startText" type="text" value="2016/06/01" maxlength="10" id="ctl00_ContentPlaceHolder1_startText" style="width:72px;" />
  45. 'µ²§ô¤é´Á<input name="ctl00$ContentPlaceHolder1$endText" type="text" value="2019/07/27" maxlength="10" id="ctl00_ContentPlaceHolder1_endText" style="width:72px;" />
  46. '<input type="submit" name="ctl00$ContentPlaceHolder1$submitBut" value="¬d¸ß" id="ctl00_ContentPlaceHolder1_submitBut" class="butn btnga" />
  47. '    <span style="float:right">
  48. '</span>
  49. '</span>
½Æ»s¥N½X
¦^´_ 1# wufonna

Book12.zip (91.57 KB)

TOP

        ÀR«ä¦Û¦b : ¡i®É¶¡¦pÆp¥Û¡j®É¶¡¹ï¤@­Ó¦³´¼¼zªº¤H¦Ó¨¥¡A´N¦pÆp¥Û¯ë¬Ã¶Q¡F¦ý¹ï·M¤H¨Ó»¡¡A«o¹³¬O¤@§âªd¤g¡A¤@ÂI»ù­È¤]¨S¦³¡C
ªð¦^¦Cªí ¤W¤@¥DÃD