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 CNVcaller安装后无法找到文件
  • ¥15 visual studio2022中文乱码无法解决
  • ¥15 关于华为5g模块mh5000-31接线问题
  • ¥15 keil L6007U报错
  • ¥15 webapi 发布到iis后无法访问
  • ¥15 初学者如何快速上手学习stm32?
  • ¥15 如何自动更换布娃娃图片上的衣服
  • ¥15 心理学eprime编程
  • ¥15 arduino esp8266开发
  • ¥15 stm32单片机通过485发送命令给驱动器控制电机转动,同样的代码f103可以控制电机转动,换到f407不能动了,但是用串口助手调试407显示发送的命令都是正确的,卡了好久了这是发送规则