我的selenium instagram bot的xpath点击一个配置文件,而不是弹出类似的框

2024-09-28 21:58:40 发布

您现在位置:Python中文网/ 问答频道 /正文

Liked by user_name and 990 others

如果您熟悉instagram,那么当您单击图片时,页面底部就是这个样子,出于某种原因,无论我选择什么xpath,它都会单击“user\u name”,而不是“990 others”。当它是一个简单的:

990 likes

它工作得很好。各种各样的XPath我都试过了:

//a[contains(@href, 'liked_by')]
//a[@class = 'zV_Nj']
//a[@class = 'zV_Nj']/span
//section/div/div/a/span

我已尝试使用以下xpath特别避免使用“user\u name”配置文件:

//section/div/div[2]/a[2]

但什么都没用,它一直在点击个人资料。有人能解释一下我做错了什么吗?我的目标是让likers框弹出。我已经做了几个小时了,请帮帮我。你知道吗

<section class="EDfFK ygqzn">
<div class="                  Igw0E     IwRSH      eGOV_     ybXk5   vwCYk                                                                                                               ">
<div class="                  Igw0E     IwRSH      eGOV_         _4EzTm                                       ItkAi                                                                       ">
<div class="                  Igw0E     IwRSH      eGOV_     ybXk5    _4EzTm                                                                                                              ">
<div class="KcRNL QnLYV  ">
<span class="_2dbep " role="link" tabindex="0" style="width: 20px; height: 20px;">
img class="_6q-tv" src="https://scontent-frt3-2.cdninstagram.com/vp/6e8be84d80c13692826b2ed1d22ecd37/5C8AFF58/t51.2885-19/s150x150/26066662_205753880002771_3331346998950363136_n.jpg" alt="ewapelak's profile picture">
</span>
</div>
</div>
</div>
<div class="Nm9Fw">
Liked by 
<a class="FPmhX notranslate cqXBL" title="ewapelak" href="/ewapelak/">ewapelak</a> 
and 
<a class="zV_Nj" href="/p/Bqrkrc5Fpwo/liked_by/">
<span>994</span> others
</a>
</div>
</div>
</section>

Tags: namedivbysectionclasshrefspanuser