0
HTML 테이블의 행에서 가장 오른쪽 셀의 내부 텍스트 만 추출하려고합니다. 이것은 HTML 코드의 작은 부분입니다. 행은 810 개 세포를 포함하고 TR 태그는 811 개 TD 태그 원하는 분야하나의 셀에서 innerText 추출
</tr><tr align="center" id="spt_inner_row_2"><td nowrap="nowrap" bgcolor="#EEEEEE" style="border-bottom: 1px solid white; border-right: 1px solid white">
300 - 305
</td><td nowrap="nowrap" bgcolor="#EEEEEE" style="border-bottom: 1px solid white; border-right: 1px solid white">
300 - 305
</td><td nowrap="nowrap" bgcolor="#EEEEEE" style="border-bottom: 1px solid white; border-right: 1px solid white">
300 - 305
</td><td nowrap="nowrap" bgcolor="#EEEEEE" style="border-bottom: 1px solid white; border-right: 1px solid white">
300 - 305
나는 현재 성공적으로 활성 시트의 열 A의 각 셀의 데이터 및 페이스트를 추출하여 사용하는 코드 :
Sub GetData()
Dim URL As String
Dim IE As InternetExplorer
Dim HTMLdoc As HTMLDocument
Dim TDelements As IHTMLElementCollection
Dim TDelement As HTMLTableCell
Dim r As Long
'For login use
Dim LoginForm As HTMLFormElement
Dim UserNameInputBox As HTMLInputElement
Dim PasswordInputBox As HTMLInputElement
URL = "https://www.whatever.com"
Set IE = New InternetExplorer
With IE
.navigate URL
.Visible = True
'Wait for page to load
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
Set HTMLdoc = .document
'Enter login info
Set LoginForm = HTMLdoc.forms(0)
'Username
Set UserNameInputBox = LoginForm.elements("username")
UserNameInputBox.Value = "username"
'Password
Set PasswordInputBox = LoginForm.elements("password")
PasswordInputBox.Value = "password"
'Get the form input button and click it
Set SignInButton = LoginForm.elements("doLogin")
SignInButton.Click
'Wait for the new page to load
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
'Auto-navigate to start page, so we need to navigate once more
.navigate URL
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
End With
'Specify how to recognize data to extract
Set TDelements = HTMLdoc.getElementById("spt_inner_row_2").getElementsByTagName("TD")
r = 0
For Each TDelement In TDelements
ActiveSheet.Range("A1").Offset(r, 0).Value = TDelement.innerText
r = r + 1
Next
End Sub
을
정말 필요한 것은 HTML 테이블 행의 마지막 (맨 오른쪽) 셀만 추출하는 것입니다. 어떤 제안?
오도록이 [** ** 링크 1 (http://stackoverflow.com/questions/17643483/trying-를 참조 to-fetch-data-from-vba-code-but-it-works-so-works-and-so/17666816 # 17666816), [** Link2 **] (http://stackoverflow.com/questions/15844342/pulling-upside-downside-capture-ratio-morningstar-com/15853293 # 15853293) 및 [** Link3 **] (http://stackoverflow.com/questions/15959008/import-web- data-in-excel-vba/15962055 # 15962055) – Santosh