douman6245 2014-11-19 10:33
浏览 99

如何从itemprop等于...的外部页面获取内容?

I would like to get content from my app page on google play to my website. Right now I get all content that is included in the .content class. But I would like to get ONLY numbers of installs. This div looks like this:

<div class="content" itemprop="numDownloads">  </div>

Anybody knows how to get the itemprop="numDownloads" from the .content class?

This is my code right now:

blade.php

<?php echo file_get_contents($_GET['url']); ?>

Script

<script>
  $(function(){
    var contentURI= 'https://play.google.com/store/apps/someapp .content';
    $('#response').load('grab.php?url='+ contentURI);
  });
</script>
  • 写回答

1条回答 默认 最新

  • doujiunai2169 2014-11-19 10:57
    关注

    You can use regular expression for this in PHP or in javascript also. Now I've implemented the PHP version, but with the pattern it could really easy to implement in javascript:

    $siteContent = ''
        . '<div class="content" itemprop="7">  </div>'
        . '<div class="content" itemprop="5768">  </div>'
        . '<div class="content" itemprop="69">  </div>';
    
    $matches =array();
    preg_match_all('/itemprop\s*=\s*[\'"]([^\'"]+)[\'"]/im', $siteContent, $matches);
    var_dump($matches[1]);
    

    The output is:

    array
      0 => string '7' (length=1)
      1 => string '5768' (length=4)
      2 => string '69' (length=2)
    
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)