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

[µo°Ý] ½Ð±Ð³oºô­¶ªþ¹Ïªí®æ¬O¦b²Ä´X???(table)

½Ð±Ð³oºô­¶­nª½±µ¶×¤J¤u§@ªí­n¦p¦ó§ï??

https://tw.stock.yahoo.com/d/i/rank.php?t=up&e=tse
Sub test()
    Set Ie = CreateObject("InternetExplorer.Application")
    Ie.Visible = True
       Ie.Navigate "https://tw.stock.yahoo.com/d/i/rank.php?t=up&e=tse"
Do While Ie.Busy Or Ie.ReadyState <> 4: DoEvents: Loop

    Dim I As Integer, S As Integer, k As Integer, J As Integer
     Dim Element
    Set Element = Ie.document.getelementsbytagname("table")
    With Sheets("sheet2")
      .Range("a1:f30").ClearContents
        For S = 2 To 2                    '¤w§ä¥Xºô­¶ªºtable¤º®e¦b 2 ¤¤
            For I = 0 To Element(S).Rows.Length - 1
                k = k + 1
                For J = 0 To Element(S).Rows(I).Cells.Length - 1   '¸ê®ÆªºÄæ¦ì¦@6¦ì
                .Cells(k, J + 1) = Element(S).Rows(I).Cells(J).innerText
                Next
            Next
        Next

    End With
    Set Element = Nothing
               
Ie.Quit
End Sub

TOP

¤w¸Ñ¨M...........

TOP

[µo°Ý] ½Ð±Ð³oºô­¶ªþ¹Ïªí®æ¬O¦b²Ä´X???(table)

https://pchome.megatime.com.tw/rank/sto0/ock03.html

½Ð±Ð³oºô­¶ªþ¹Ïªí®æ¬O¦b²Ä´X???(table)

¥»©«³Ì«á¥Ñ GBKEE ©ó 2020-5-10 15:20 ½s¿è

¦^´_ 3# t8899

  1. Option Explicit
  2. Sub Ex()
  3.     Dim R As Integer, C As Integer
  4.     With New InternetExplorer  '**³]©w¤Þ¥Î¶µ¥Ø¥[¤J-->   Microsoft Internet Controls***
  5.        .Visible = True
  6.         .Navigate "https://pchome.megatime.com.tw/rank/sto0/ock03.html"
  7.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  8.                      '<table style="margin-top: 10px;" cellspacing="1" cellpadding="0" **ºô­¶ªº¤º®e**
  9.          With .Document.querySelector("table[style='margin-top: 10px;'][cellspacing='1'][cellpadding='0']")
  10.          '' With .Document.all.tags("table")(0) '** ¤]¥i¥H
  11.             For R = 0 To .Rows.Length - 1
  12.                 For C = 0 To .Rows(R).Cells.Length - 1
  13.                     ActiveSheet.Cells(R + 1, C + 1) = .Rows(R).Cells(C).innerText
  14.                 Next
  15.             Next
  16.         End With
  17.          .Quit
  18.       End With
  19. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_  t8899
GBKEE µoªí©ó 2020-5-10 15:13


¤S¾Ç²ß¨ì·sªº§ìªk, ÁÂÁ«ü¾É!

TOP

        ÀR«ä¦Û¦b : ¹D¼w¬O´£ª@¦Û§Úªº©ú¿O¡A¤£¸Ó¬O¨þ¥¸§O¤HªºÃ@¤l¡C
ªð¦^¦Cªí ¤W¤@¥DÃD