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

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);
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题