<?xml version="1.0" encoding="UTF-8"?>
<div id="app" class="grid bg-local font-body justify-center" style="background-image: url("/img/picture.jpg");">
<div data-v-f7g8b83d=" " data-fruit-code="**I WANT TO GET WHAT'S IN HERE**" class="note relative bg-background items-center select-none w-56 sm:w-64 pb-4" style="transform: rotate(6deg);"/>
<div data-v-f7g8b83d=" " data-fruit-code="**I WANT TO GET WHAT'S IN HERE 1**" class="note relative bg-background items-center select-none w-56 sm:w-64 pb-4" style="transform: rotate(6deg);"/>
<div data-v-f7g8b83d=" " data-fruit-code="**I WANT TO GET WHAT'S IN HERE 2**" class="note relative bg-background items-center select-none w-56 sm:w-64 pb-4" style="transform: rotate(6deg);"/>
<div data-v-f7g8b83d=" " data-fruit-code="**I WANT TO GET WHAT'S IN HERE 3**" class="note relative bg-background items-center select-none w-56 sm:w-64 pb-4" style="transform: rotate(6deg);"/>
<div data-v-f7g8b83d=" " data-fruit-code="**I WANT TO GET WHAT'S IN HERE 4**" class="note relative bg-background items-center select-none w-56 sm:w-64 pb-4" style="transform: rotate(6deg);"/>
</div>
我正在尝试构建一个机器人来抓取特定网站。我希望能够获取与“data-fruit-code”相关的文本。
我想出了这个:
//*[@id="app"]/div[2]/div
和这个:
//*[@data-fruit-code]
然而,两者都只突出显示整个 div。我觉得我在这里错过了一些东西。我可以添加什么或者如何修复现有的 XPATH 命令,以便它只获取“data-fruit-code”文本?
我尝试添加 text() 和 word() 但这些对我来说也不起作用。
以下是我用来获取帮助的一些参考资料。
https://devhints.io/xpath#class-check
https://developer.mozilla.org/en-US/docs/Web/XPath
MM们
拉丁的传说
相关分类