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

[¤À¨É] Âà´«ieª«¥ó»yªk¬°Selenium(chrome) ?

[¤À¨É] Âà´«ieª«¥ó»yªk¬°Selenium(chrome) ?

Sub IE345678()
    Set Ie = CreateObject("InternetExplorer.Application")
    Ie.Navigate "https://mis.twse.com.tw/stock/group.jsp?type=fixed&ex=tse&ind=TIDX#STATISTICS"
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("sheet1")
      .Range("a1:f17").ClearContents
        For S = 4 To 5               
            For I = 0 To Element(S).Rows.Length - 1
                k = k + 1
                For J = 0 To Element(S).Rows(I).Cells.Length - 1  
               .Cells(k, J + 1) = Element(S).Rows(I).Cells(J).innerText
                Next
            Next
        Next
    End With
    Set Element = Nothing
end sub

½Ð±Ð¦¹ieª«¥ó¦p¦óÂà´«¦¨Selenium(chrome)ªº»yªk?

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-10-19 11:55 ½s¿è

¦^´_ 32# singo1232001


¥t¥~µ¹¤@¨Ç¨S¦w¸Ë¹Lseleniumªº³sµ²
http://forum.twbts.com/thread-23709-1-3.html

ª¦ÂΧì¤Wº¦¶^¤U¤T¨¤§Î.zip (15.57 KB)

TOP

¦^´_ 31# singo1232001


§ó¥¿¤@¤U(³æ¦C ¸ò Âù¦C)

Sub test()
Set DRIVER = CreateObject("Selenium.ChromeDriver")
DRIVER.Get "https://tw.stock.yahoo.com/quote/1101.TW"
Cells.ClearContents
Set ID0 = DRIVER.FindElementByID("qsp-overview-realtime-info")
Set UL1 = ID0.FindElementsBytag("ul")(1)
'³æ¦C
sp = Split(UL1.Text, Chr(10))
Cells(1, 1).Resize(UBound(sp) + 1, 1) = Application.Transpose(sp)

'Âù¦C
u2 = UBound(sp) / 2
ReDim ar(1 To u2, 1 To 2)
For i = 0 To UBound(sp) Step 2
w = w + 1
ar(w, 1) = sp(i)
ar(w, 2) = sp(i + 1)
Next
Cells(1, 3).Resize(UBound(ar), 2) = ar
End Sub

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-10-19 10:54 ½s¿è

¦^´_ 30# t8899

Sub test()
Set DRIVER = CreateObject("Selenium.ChromeDriver")
DRIVER.Get "https://tw.stock.yahoo.com/quote/1101.TW"
Cells.ClearContents
Set ID0 = DRIVER.FindElementByID("qsp-overview-realtime-info")
Set UL1 = ID0.FindElementsBytag("ul")(1)

sp = Split(UL1.Text, Chr(10))
Cells(1, 1).Resize(UBound(sp), 1) = Application.Transpose(sp)
End Sub

¸É¥R ¤W¤Uº¦¶^ªº¤T¨¤§Î ¸ò­t¸¹ ¤W­z¨Ã¨S¦³°µ¯S§O³B²z
­Y¦³»Ý­n´N¥²¶·§Q¥Îtag³æ¿W§ä¥X¨Ó,¨Ì·Ó¤W¤T¨¤§Î »P ¤U¤T¨¤§Î ­Ó§O¤ñ¹ï­×§ï¥¿­t¼Æ

TOP

¥»©«³Ì«á¥Ñ t8899 ©ó 2022-10-18 20:36 ½s¿è

¦^´_ 28# singo1232001

Sub test()
Set DRIVER = CreateObject("Selenium.ChromeDriver")
DRIVER.Get "https://tw.stock.yahoo.com/quote/1101.TW"
Set td = DRIVER.FindElementByXPath("//*[@id=""qsp-overview-realtime-info""]/div[2]/div[2]/div/ul")
Cells.ClearContents
' td.AsTable.ToExcel Cells(1, 1)
End Sub
¹Ï¤¤®Ø°_¨Óªº¦Ç¦â®Ø®Ø¤£¬O¤@­Ótable ??
­n¦p¦ó¥Htable¤è¦¡¶×¤Jexcel ?

TOP

¦^´_  t8899


«Øij§A§âµ{¦¡½X¶K¥X¨Ó¦n¤F

¥i¯à¬O¨S¦³CLOSE±¼¤K

©ÎªÌ»Ý¨D»¡¤@¤U
singo1232001 µoªí©ó 2022-10-16 07:42


¸Ñ¨M¤F
§Ú¥Îpublic w1 , ¤S¥Î DIM w1 , §âdim w1 ®³±¼´N¦n¤F
ÁÂÁÂ!

TOP

¦^´_ 27# t8899


«Øij§A§âµ{¦¡½X¶K¥X¨Ó¦n¤F

¥i¯à¬O¨S¦³CLOSE±¼¤K

©ÎªÌ»Ý¨D»¡¤@¤U

TOP

¦^´_  t8899

³Ì¤W­±°£¤F
publice driver as object
¦h¥[¤@¦æ
public w1,w2


w1 ¸òw2 ¨S¸ò¹L¥h
...
singo1232001 µoªí©ó 2022-10-16 02:16


¸Õªºµ²ªG ¥u¯à¥Î DRIVER.SwitchToPreviousWindow    ?
DRIVER.SwitchToWindowByTitle w1 '²Ä¤@­Ó¥æ©ö©Ò
DRIVER.SwitchToWindowByTitle w2 '²Ä¤G­Ó´Á¥æ©Ò
DRIVER.SwitchToNextWindow
³o3­Ó¤£¦æ?

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-10-16 06:29 ½s¿è

¸É¥R»¡©ú¤@¤U

¥Îpublic ¬O¥þ³¡ªº¼Ò²Õmodule ¥]¬Aªí³æuserform ³£·|¦Y¨ì³á
   
¦pªG¨ä¥L¼Ò²Õ¤]¦³¥Î¨ì ´N¥Îpublic

¦pªG¤£·Qµ¹¨ä¥L¼Ò²ÕModule ªí³æuserform¥Îªº¸Ü

§ï¥Î
dim driver as object
dim w1,w2

¥Îdim ªº¸Ü ¦P¼Ò²Õ¤ºªº©Ò¦³sub³£¯à¥Î ¨ä¥L¼Ò²Õ¤ºªº¥Î¤£¤F

¦]¬°©È¦b¨ä¥L¼Ò²Õªºsub¤]¦³¥Î¨ìw1,w2 ¨ì®É­Ô½Ä¬ð

TOP

¦^´_ 24# t8899

³Ì¤W­±°£¤F
publice driver as object
¦h¥[¤@¦æ
public w1,w2


w1 ¸òw2 ¨S¸ò¹L¥h
¥Ø«e¬Ý¨Ó¬O ""

TOP

        ÀR«ä¦Û¦b : ¤H¥Í¤£¤@©w²y²y¬O¦n²y¡A¦ý¬O¦³¾ú½mªº±j¥´ªÌ¡AÀH®É³£¥i¥H´§´Î¡C
ªð¦^¦Cªí ¤W¤@¥DÃD