【发布时间】:2021-02-03 06:26:54
【问题描述】:
我正在尝试使用下面的 VBA 代码从 this HTML page 中提取价格:
这是 HTML sn-p:
<div class="box-text box-text-products">
<div class="title-wrapper">
<p class="category uppercase is-smaller no-text-overflow product-cat op-7">
Xikar Lighters
</p>
<p class="name product-title">
<a href="https://www.havanahouse.co.uk/product/xikar-allume-single-jet-flame-racing-cigar-lighter-bluewhite-stripe/">Xikar Allume Single Jet Flame Racing Cigar Lighter – Blue/White Stripe</a>
</p>
</div>
<div class="price-wrapper">
<span class="price">
<del>
<span class="woocommerce-Price-amount amount">
<span class="woocommerce-Price-currencySymbol">£</span>48.00
</span>
</del>
<ins>
<span class="woocommerce-Price-amount amount">
<span class="woocommerce-Price-currencySymbol">£</span>45.00
</span>
</ins>
</span>
</div>
</div>
<!-- box-text -->undefined</div>undefined<!-- box -->undefined</div>undefined<!-- .col-inner -->undefined</div>undefined<!-- col -->
我正在使用以下代码,但出现错误:
For Each oElement In oHtml.getElementsByClassName("woocommerce-Price-amoun t amount")
If oElement.getElementsByTagName("del") Then Exit For
If oElement.innerText <> 0 Then
Cells(counter, 3) = CDbl(oElement.innerText)
counter = counter + 1
End If
Next oElement
【问题讨论】:
-
请在您的帖子中包含错误信息。
-
@Suren Grigoryan,所以你就是这样一个人,他只希望收到针对你的问题的答案,而不是支持它们或接受它们作为解决方案。看看你以前的帖子:即使你在那里得到了合格的答案,你什么也没做。但是,我已经拿出了我的解决方案。谢谢。
-
@SIM - 嗨,我现在才有机会好好看看这个,但你提供的东西已经消失了。不确定我需要做什么才能“投票”?答案
-
@SIM - 无论如何感谢您的回答,如果您指出我如何做到这一点的正确方向,我们很乐意支持或接受解决方案。
标签: excel web-scraping vba