如何读取HttpWebRequest中的某个字符串

How to read a certain string in HttWebRequest

我正在尝试使用 HTTPWebRequest 从多个网站获取价格标签

这是一个更难的 LINK 我正在尝试从组合框中获取价格标签

这是一个更简单的(我认为),LINK

如何只解析价格标签?

这是 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