doushiposong30622 2018-05-08 11:09
浏览 70
已采纳

php如何用google play scraper获取元素的值?

I am using google play scraper API calling html inputs and get their values the problem is that there is 2 html inputs having the same name classes, so when I give the path pointing to theme I get the same result for both , I am facing this conflict of classes when I am giving the path to Installs html input and Updated html input , this is the php code that I am using to call the Installs html input :

$downloadsNode = $crawler->filter('.xyOfqd > .hAyfc > .htlgb > div > span ');
        if ($downloadsNode->count()) {
            $downloads = trim($downloadsNode->text());
        } else {
            $downloads = null;
        }

and as result I Get the Updated field value cause it shares the same classes name.

this is the Html code source :

<div class="JHTxhe"><div class="xyOfqd"><div class="hAyfc"><div class="BgcNfc">Updated</div><span class="htlgb"><div><span class="htlgb">May 3, 2018</span></div></span></div><div class="hAyfc"><div class="BgcNfc">Size</div><span class="htlgb"><div><span class="htlgb">Varies with device</span></div></span></div><div class="hAyfc"><div class="BgcNfc">Installs</div><span class="htlgb"><div><span class="htlgb">1,000,000,000+</span></div></span></div><div class="hAyfc"><div class="BgcNfc">Current Version</div><span class="htlgb"><div><span class="htlgb">Varies with device</span></div></span></div><div class="hAyfc"><div class="BgcNfc">Requires Android</div><span class="htlgb"><div><span class="htlgb">Varies with device</span></div></span></div><div class="hAyfc"><div class="BgcNfc">Content Rating</div><span class="htlgb"><div><span class="htlgb"><div>Rated for 12+</div><div>Parental Guidance Recommended</div><div><a href="https://support.google.com/googleplay?p=appgame_ratings">Learn More</a></div></span></div></span></div><div class="hAyfc"><div class="BgcNfc">Interactive Elements</div><span class="htlgb"><div><span class="htlgb">Users Interact, Digital Purchases</span></div></span></div><c-wiz jsrenderer="HwUY7e" jsshadow="" jsdata="deferred-i23" data-p="%.@.[&quot;com.google.android.youtube&quot;,7]
]

could you pls help me on that

  • 写回答

1条回答 默认 最新

  • dongyong1400 2018-05-09 15:59
    关注

    This is how I solved this Issue , I have added eq() function and it solved my problem .

    $downloadsNode = $crawler->filter('.xyOfqd > .hAyfc > .htlgb > div > span')->eq(2);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大