0
我试图提取GTM中的产品描述标记的全部文本(部署结构化数据,yada yada)。我面临的问题是,我试图提取的文本的一半存在于产品页面上的“Read More ...”链接中。在“ReadMore ...”触发器中连接文本
页面上的元素的布局已呈现后是:
<p class="product-description">
"This is the first part of the description of this product! It is read, warm,"
<span class="morecontent" display="inline"> //inline when expanded, none when clicked
<span class="readmore-description">
"fuzzy, and black."
</span>
<a class="more-link">&nsbp;Less</a> //&nsbp;Less when expanded, &nsbp;Read More.. when clicked
</span>
</p>
我没有得到远......所有到目前为止,我已经试过是:
function() {
var description = document.querySelector("p.product-description");
return description;
}
我想得到“这是这个产品的第一部分描述!它被读取,温暖,模糊和黑色。”背部。
谢谢!
感谢这个 - 我认为这是类似于页面是如何架构已经。你知道我怎样才能用一个函数来提取完整的描述(不是分成两部分)吗? 'function(){ var description = document.querySelector(“p.product-description”); return description; }'是我现在使用的,但当然不起作用。我认为脚本需要以某种方式连接。 – PercentSharp
仅当您分别提取它们,然后将它们连接到一个字符串中。 – zsawaf