beijing0305
New Member
- Joined
- Feb 14, 2021
- Messages
- 9
- Office Version
- 2016
- Platform
- Windows
I have tried a couple of approach to scrape a website with simple data layout, but was not successful with the following 3 issues:
1) tweaking the TagName "tabble", "tr", "tb", not resulting desirable results
2) when (1) was able to pick up the title row, unicode result display the Chinese Character as ???
3) Pagination - probably will need to add another loop to pick up page 3, etc.
Thanks in advance for your help.
Bei
1) tweaking the TagName "tabble", "tr", "tb", not resulting desirable results
2) when (1) was able to pick up the title row, unicode result display the Chinese Character as ???
3) Pagination - probably will need to add another loop to pick up page 3, etc.
Thanks in advance for your help.
Bei
VBA Code:
Sub CAACCertVendorPartListXML()
Dim XMLPage As New MSXML2.XMLHTTP60
Dim HTMLDoc As New MSHTML.HTMLDocument
XMLPage.Open "GET", "http://fsop.caac.gov.cn/g145/CARS/WebSiteQueryServlet?method=loadAircraftConditionsResultPage&enterpriseName=&licenceCode=&partsNumber=&partsName=&ataChaptersection=", False
XMLPage.send
HTMLDoc.body.innerHTML = XMLPage.responseText
ProcessHTMLPage HTMLDoc
End Sub
VBA Code:
Sub ProcessHTMLPage(HTMLPage As MSHTML.HTMLDocument)
Dim HTMLTable As MSHTML.IHTMLElement
Dim HTMLTables As MSHTML.IHTMLElementCollection
Dim HTMLRow As MSHTML.IHTMLElement
Dim HTMLCell As MSHTML.IHTMLElement
Set HTMLTables = HTMLPage.getElementsByTagName("tbody")
For Each HTMLTable In HTMLTables
Debug.Print HTMLTable.tagName
For Each HTMLRow In HTMLTable.getElementsByTagName("tr")
'Debug.Print HTMLRow.Children
For Each HTMLCell In HTMLRow.getElementsByTagName("td")
Debug.Print vbTab & HTMLCell.innerText
Next HTMLCell
Next HTMLRow
Next HTMLTable
End Sub