如何使用VBA从HTML中提取属性

我需要使用VBA从html的本部分中提取sku(CS060120)

尝试使用getattribute和getElementsbyTag(和Class)Name,但是我无法获得想要的返回值。有人知道该怎么做吗?

<section class="product_options">
    <header>
        <h1>
            60' x 120' niceRink CS Liner
        </h1>
    </header>
    <vue-product-options 
        v-bind:product-opts="[]" 
        v-bind:configurable-payload="{&quot;product_option&quot;:{&quot;extension_attributes&quot;:{&quot;configurable_item_options&quot;:[]}}}" 
        v-bind:liner-types="{&quot;good&quot;:16,&quot;better&quot;:14,&quot;best&quot;:15}" 
        v-bind:is-folded-or-rolled-liner-sku="false" 
        v-bind:bundle-payload="{&quot;product_option&quot;:{&quot;extension_attributes&quot;:{&quot;bundle_options&quot;:[]}}}" 
        v-bind:tier-prices="[]" 
        v-bind:is-wholesale-only="false" 
        v-bind:prices-index="{}" 
        v-bind:options-map="{}" 
        v-bind:is-configurable="false" 
        v-bind:is-rink-liner="false" 
        v-bind:is-liner-sku="true" 
        v-bind:is-bundle="false" product-type="undefined" price="612" sku="CS060120" image="https://www.nicerink.com/media/catalog/product/l/i/liner_1.jpg" magento-base-url="https://www.nicerink.com" name="60' x 120' niceRink CS Liner">
    </vue-product-options>
    <div class="product_options_panel package_cta">
        <h3>
            Looking for a full Rink Package?
        </h3>

        <p>
            We've got you covered!
        </p>

        <a class="button dark" href="/rink-builder">
            Rink Packages
        </a>
    </div>
</section>

这是我正在尝试的:

ieDoc.getElementsByClassname("product_options")(0).getattribute("sku")
likelele 回答:如何使用VBA从HTML中提取属性

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    alert($(".sdfv").attr("sku"));
  });
});
</script>
</head>
<body>

<vue-product-options class="sdfv" sku="CS060120"></vue-product-options>

<button>Click the button to get sku value</button>

</body>
</html>

,

尝试使用属性选择器

Debug.Print ie.document.querySelector("[sku]").getAttribute("sku")

如果需要更具体,可以添加类型选择器,使其变为

Debug.Print ie.document.querySelector("vue-product-options[sku]").getAttribute("sku")
本文链接:https://www.f2er.com/3149796.html

大家都在问