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 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形