我有以下
“ PRICE
40,06€“
它尽可能地包含在notepad ++空格和制表符中,我使用了类似以下的方法来获取数字,但什么也没有发生。.我想获取40,06€
Function ExtractAmount(data As String) As Variant
Dim s As String
s = Split(data, "PRICE")(5)
ExtractAmount = CCur(Val(s))
End Function
我叫
Set price = ie.Document.querySelector(".price")
wks.Cells(i, "E").Value = ExtractAmount(price.innerText)
我该怎么办?谢谢
**以下网址
https://www.overshop.gr/index.php?route=product/product&product_id=101&search=wd10ezex
或者由于价格短语短语“从40欧元中扣除40,50欧元”而无法获得一个选择者的金额
答案 0 :(得分:2)
您需要其他的类选择器
text = IE.document.querySelector(".price-val").innerText
VBA:
Option Explicit
Public Sub GetInfo()
Dim IE As New InternetExplorer, text As String
With IE
.Visible = True
.navigate2 "https://www.overshop.gr/index.php?route=product/product&product_id=10858"
While .Busy Or .readyState < 4: DoEvents: Wend
text = IE.document.querySelector(".price-val").innerText
Debug.Print Trim$(text)
.Quit
End With
End Sub
如果测试是否存在不同的类,例如,可以使用Or css选择器语法。新价格
Option Explicit
Public Sub GetInfo()
Dim IE As New InternetExplorer, text As String
With IE
.Visible = True
.navigate "https://www.overshop.gr/index.php?route=product/product&product_id=101&search=wd10ezex"
While .Busy Or .readyState < 4: DoEvents: Wend
text = IE.document.querySelector(".price-val, .price-new").innerText
Debug.Print Trim(Trim$(text))
.Quit
End With
End Sub