¼ÐÃD:
[µo°Ý]
½Ð°Ý¦p¦ó®»¨úºô¶n¿é¤JªºTABLE¨ìªí®æ¡AÁÂÁÂ
[¥´¦L¥»¶]
§@ªÌ:
wufonna
®É¶¡:
2019-7-27 20:22
¼ÐÃD:
½Ð°Ý¦p¦ó®»¨úºô¶n¿é¤JªºTABLE¨ìªí®æ¡AÁÂÁÂ
°Ñ¦Ò
http://forum.twbts.com/viewthread.php?tid=9511
½Ð°Ý¨ºùØ¿ù¡A¦pªGDaten¥Î NOW()¨ú1200¤Ñ¦p¦ó§ï¡AÁÂÁÂ
Sub Ex()
Dim i As Integer, s As Integer, k As Integer, A, ii, j
Dim co_id As String, isnew As String, season As String
'²Ä¤@©u 01,²Ä¤G©u 02²Ä¤T©u 03,²Ä¥|©u 04.
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "https://www.cnyes.com/twstock/ps_historyprice/1216.htm"
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
With .document
For Each A In .getelementsbytagname("INPUT")
If A.Name = "ctl00$ContentPlaceHolder1$startText" Then A.Value = "2016/06/01"
Next
For Each A In .getelementsbytagname("INPUT")
If A.Name = "ctl00$ContentPlaceHolder1$endText" Then A.Value = "2019/07/27"
Next
For Each A In .getelementsbytagname("INPUT")
If Trim(A.Value) = "¬d¸ß" And A.Name = "ctl00$ContentPlaceHolder1$submitBut" Then A.Click '«ö¤U[¬d¸ß]Áä
Next
End With
On Error Resume Next '***¦³¨Çtable¨SRows¸ê®Æ·|²£¥Í¿ù»~ ¤£²z·|¥¦,µ{¦¡Ä~Äò¨«
Set A = .document.getelementsbytagname("table")(0).outerhtml
With ActiveSheet
.Cells.Clear
'************************
' For ii = 0 To A.Length - 1 '¤£ª¾¹Dtable½d³ò¦b¦ó³B: ±q0¶}©l
'******************************
For ii = 11 To A.Length - 1 ''±q11¶}©l ¥Î Debug.Print ii §ä¥X©Òn¸ê®Æªºtable½d³ò
For i = 0 To A(ii).Rows.Length - 1 '¼g¤J¸ê®Æ
'Debug.Print ii ¥i§ä¥X©Òn¸ê®Æªº table ½d³ò
k = k + 1
For j = 0 To 5
Cells(k, j + 1) = A(ii).Rows(i).Cells(j).innerText
Next
Next
Next
End With
' .Quit 'Ãö³¬ºô¶
End With
End Sub
'vba ¾Þ§@ie¶×¤J¸ê®Æ 'http://forum.twbts.com/viewthread.php?tid=9511
'¦p¦ó¦bºô¶·j´Mµ²ªG«á¡A¦A«ö®É¶¡«ö¶s
'ºô¶µn¤J-«ö¶s°ÝÃD
'<div class="mbx bd3" enableviewstate="false">
'<h3 class="tabName"><span id="ctl00_ContentPlaceHolder1_titleLab">²Î¤@ ¾ú¥v¦æ±¡</span></h3>
'<div class="blank10" enableviewstate="false"></div>
'<span class="srchyear2" >
'¶}©l¤é´Á<input name="ctl00$ContentPlaceHolder1$startText" type="text" value="2016/06/01" maxlength="10" id="ctl00_ContentPlaceHolder1_startText" style="width:72px;" />
'µ²§ô¤é´Á<input name="ctl00$ContentPlaceHolder1$endText" type="text" value="2019/07/27" maxlength="10" id="ctl00_ContentPlaceHolder1_endText" style="width:72px;" />
'<input type="submit" name="ctl00$ContentPlaceHolder1$submitBut" value="¬d¸ß" id="ctl00_ContentPlaceHolder1_submitBut" class="butn btnga" />
' <span style="float:right">
'</span>
'</span>
½Æ»s¥N½X
§@ªÌ:
wufonna
®É¶¡:
2019-7-27 23:35
§ï³o¼Ë¥i¦æ¡A¦ý¬°¤°»ò²Ä¤G¦¸°õ¦æ·|¿ù»~
Sub Ex()
Dim i As Integer, s As Integer, k As Integer, A, ii, j
Dim co_id As String, isnew As String, season As String
'²Ä¤@©u 01,²Ä¤G©u 02²Ä¤T©u 03,²Ä¥|©u 04.
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "https://www.cnyes.com/twstock/ps_historyprice/1216.htm"
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
With .document
For Each A In .getElementsByTagName("INPUT")
If A.Name = "ctl00$ContentPlaceHolder1$startText" Then A.Value = Format(Now - 1500, "yyyy/mm/dd") '"2016/06/01"
Next
For Each A In .getElementsByTagName("INPUT")
If A.Name = "ctl00$ContentPlaceHolder1$endText" Then A.Value = Format(Now, "yyyy/mm/dd") '"2019/07/27"
Next
For Each A In .getElementsByTagName("INPUT")
If Trim(A.Value) = "¬d¸ß" And A.Name = "ctl00$ContentPlaceHolder1$submitBut" Then A.Click '«ö¤U[¬d¸ß]Áä
Next
End With
' On Error Resume Next '***¦³¨Çtable¨SRows¸ê®Æ·|²£¥Í¿ù»~ ¤£²z·|¥¦,µ{¦¡Ä~Äò¨«
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
Set A = .document.getElementsByTagName("table")(0)
' On Error Resume Next
With ActiveSheet
.Cells.Clear
For i = 0 To A.Rows.Length - 1
For j = 0 To A.Rows(i).Cells.Length - 1
.Cells(i + 1, j + 1) = A.Rows(i).Cells(j).innerText
Debug.Print i
Next
Next
End With
.Quit 'Ãö³¬ºô¶
End With
End Sub
'vba ¾Þ§@ie¶×¤J¸ê®Æ 'http://forum.twbts.com/viewthread.php?tid=9511
'¦p¦ó¦bºô¶·j´Mµ²ªG«á¡A¦A«ö®É¶¡«ö¶s
'ºô¶µn¤J-«ö¶s°ÝÃD
'<div class="mbx bd3" enableviewstate="false">
'<h3 class="tabName"><span id="ctl00_ContentPlaceHolder1_titleLab">²Î¤@ ¾ú¥v¦æ±¡</span></h3>
'<div class="blank10" enableviewstate="false"></div>
'<span class="srchyear2" >
'¶}©l¤é´Á<input name="ctl00$ContentPlaceHolder1$startText" type="text" value="2016/06/01" maxlength="10" id="ctl00_ContentPlaceHolder1_startText" style="width:72px;" />
'µ²§ô¤é´Á<input name="ctl00$ContentPlaceHolder1$endText" type="text" value="2019/07/27" maxlength="10" id="ctl00_ContentPlaceHolder1_endText" style="width:72px;" />
'<input type="submit" name="ctl00$ContentPlaceHolder1$submitBut" value="¬d¸ß" id="ctl00_ContentPlaceHolder1_submitBut" class="butn btnga" />
' <span style="float:right">
'</span>
'</span>
½Æ»s¥N½X
¦^´_
1#
wufonna
Åwªï¥úÁ{ ³Â»¶®a±Ú°Q½×ª©ª© (http://forum.twbts.com/)