更新时间:2023-11-18 22:25:46
在 XPath 中索引从 1 个位置开始,因此
In XPath index starts from 1 position, therefore
//div[@class="post-content"]//img[2]
如果您必须在 div[@class="post-content"]
中选择每个第二个 img
,
应该可以正常工作.如果您必须从 div[@class="post-content"]
中的所有图像中仅选择第二个 img
,请使用:
should work correctly if you have to select each 2nd img
in div[@class="post-content"]
. If you have to select only 2nd img
from all images that are in div[@class="post-content"]
, use:
(//div[@class="post-content"]//img)[2]