php - Symfony's DomCrawler does not find a specific tag -


i'm using domcrawler data google play page , works in 99% of cases, except stumbled upon page can not find specific div. check html code , there. code is

$autoloader = require __dir__.'\vendor\autoload.php'; use symfony\component\domcrawler\crawler;  $app_id = 'com.balintinfotech.sinhalesekeyboardfree';  $response = file_get_contents('https://play.google.com/store/apps/details?id='.$app_id); $crawler = new crawler($response); echo $crawler->filter('div[itemprop="datepublished"]')->text(); 

when run specific page

php fatal error: uncaught invalidargumentexception: current node list empty.

however, if use other id, desired result. page breaks domcrawler

as correctly figured out, doesn't happen in english version, in spanish one.

one difference spot comment user saying නියමයි ඈ. there seems bothering crawler there. if replace null characted (\x00) empty string, correctly gets you're looking for:

<?php $app_id = 'com.balintinfotech.sinhalesekeyboardfree'; $response = file_get_contents('https://play.google.com/store/apps/details?hl=en&id='.$app_id); $response = str_replace("\x00", "", $response); $crawler = new symfony\component\domcrawler\crawler($response); var_dump($crawler->filter('div[itemprop="datepublished"]')->text()); // string(14) "march 14, 2017" 

i'll try more this.


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -