Html 如何用vba删除网页刮片后的引号

Html 如何用vba删除网页刮片后的引号,html,excel,vba,web-scraping,Html,Excel,Vba,Web Scraping,我开始抓取网页,当我复制单元格时,我注意到以下几点 " In stock " " 4 to 10 bus days " " 4 to 10 bus days " " 4 to 10 bus days " 我试图将它们与额外的CR LF一起移除,以便获得以下内容 In stock 4 to 10 bus days 4 to 10 bus days 4 to 10 bus days 我尝试了以下不起作用的方法 Set availability = ie.Document.querySelecto

我开始抓取网页,当我复制单元格时,我注意到以下几点

"
In stock
"
"
4 to 10 bus days
"
"
4 to 10 bus days
"
"
4 to 10 bus days
"
我试图将它们与额外的CR LF一起移除,以便获得以下内容

In stock
4 to 10 bus days
4 to 10 bus days
4 to 10 bus days
我尝试了以下不起作用的方法

Set availability = ie.Document.querySelector(".product-section")
Dim arr() As String
arr = Split(Replace(Trim(availability.innerText), Chr(34), ""), ":")
wks.Cells(i, "D").Value = (arr(UBound(arr)))

Set availability = ie.Document.querySelector(".product-section")
Dim arr() As String
arr = Split(Replace(Trim(availability.innerText), """", ""), ":")
wks.Cells(i, "D").Value = (arr(UBound(arr)))

Set availability = ie.Document.querySelector(".product-section")
Dim arr() As String
arr = Split(Trim(availability.innerText), ":")
wks.Cells(i, "D").Value = (arr(UBound(arr)))
这和网页有关吗?其他网页是否有正常输出

我怎样才能修好它

第一个URL是 和
这表示库存中

在这种情况下,最好使用直接选择器,但在某些链接中,如果缺货,第二类更改为
。prod Stock out
,则需要进行测试以确定要使用哪个子类选择器

CSS:

VBA:



例如,我期望的结果类似于库存中的4到10个公交日4到10个公交日4到10个公交日4到10个公交日我刚刚翻译了它们:)让我们来。我将Dim arr()作为字符串arr=Split(替换(availability.innerText,Chr$(34),vbNullString),“:”)但是没什么sameI只想要最后一个单词列表中只有一项没有引号另一项保留2 CR和LF带有引号每行生成一个带有上述内容的数组。所以我需要每个数组的最后一个字没有引号,当我从数组中取出它时,从引号cr和lf中是完美的,但是通过运行它,结果是完全错误的为什么?
.product-section .prod-stock
ie.document.querySelector(".product-section .prod-stock").innerText
Option Explicit
Public Sub GetInfo()
    Dim ie As New InternetExplorer, wks As Worksheet
    Dim j As Long, urls()
    Set wks = ThisWorkbook.Worksheets("Sheet1")
    urls = Application.Transpose(wks.Range("A1:A2").Value) 'adjust for range containing all urls
    With ie
        .Visible = True

        For j = LBound(urls) To UBound(urls)
            .Navigate2 urls(j)

            While .Busy Or .readyState < 4: DoEvents: Wend

            wks.Cells(j, "C") = .document.querySelector(".col-sm-8 h1").innerText

            If .document.getElementsByClassName("product-section")(0).getElementsByClassName("prod-stock").Length = 0 Then
                wks.Cells(j, "D") = .document.querySelector(".product-section .prod-stock-out").innerText
            Else
                wks.Cells(j, "D") = .document.querySelector(".product-section .prod-stock").innerText
            End If
        Next
        .Quit
    End With
End Sub
If .document.querySelectorAll(".product-section .prod-stock").Length = 0 Then
    wks.Cells(j, "D") = .document.querySelector(".product-section .prod-stock-out").innerText
Else
    wks.Cells(j, "D") = .document.querySelector(".product-section .prod-stock").innerText
End If