答案 0 :(得分:0)
这是VBA的答案,很容易移植到.Net。
Sub test()
'Add a reference to MSXML 6.0
Dim getreq As New MSXML2.ServerXMLHTTP60
Dim html As Object: Set html = CreateObject("htmlfile")
Dim elements As Object
Dim element As Object
'Get the HTML from the server
With getreq
.Open "GET", "http://us.bape.com/collections/men/products/1d30-141-006"
.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko"
.send
.waitForResponse 5
'Create an in memory HTML document with the page's HTML
html.body.innerhtml = .responseText
End With
'Print out the InnerText, use getelementbyid to find the element
Debug.Print html.getelementbyid("product-select").innertext
'If there are multiple options, find the element, then iterate the options
'Set elements = html.getelementbyid("product-select").getElementsByTagName("option")
'iterate the options
'For Each element In elements
' Debug.Print element.innertext
'Next
End Sub