PHP 通过APP包名爬取goole商店素材

PHP 通过APP包名爬取goole商店素材

 

一, 实验目的:通过APP 包名爬取goole商店素材

 

二, 前期准备

  1, 能FQ、一个合法的包名。

  2, 我们需要一个php html解析工具,这里我选择的是GitHub上的一个包,在你里项目composer.json中添加 "require": {"bupt1987/html-parser": "dev-master"}, 然后composer install就可以安装了。 

     https://github.com/daorli/HtmlDomFilter这是GitHub地址,更多的使用方法请查看。觉得好用别忘了给人家一个star。

 

 三, 实验开始

  //首先我们建立一个入口函数  传递一个包名。 这里以微信为例(微信团队看到了,请给我点推广费哦)!

public function getGoolePaly($package_name='com.tencent.mm'){
$url = 'https://play.google.com/store/apps/details?id=' . $package_name; //拼接一个有效的goole store play地址
$html = creativeGet($url); //creativeGet这个函数请见我的上一篇文章 https://www.cnblogs.com/onlyzc/p/9519330.html 中。 $dom = new \HtmlParser\ParserDom($html); //这个就是composer 安装的包 传入HTML dom
$info = [];
$info['app_name'] = $dom->find('h1[itemprop="name"]',0)->getPlainText(); //APP name 找到属性 itemprop="name" 的H1的内容

$info['des'] = $dom->find('[itemprop="description"]',0)->getAttr('content'); //类似上述 获取 App description $info['icon'] = $dom->find('img[itemprop="image"]',0)->getAttr('src'); //类似上述 获取 App icon的下载链接

$type = $dom->find('a[itemprop="genre"]',0)->getAttr('href'); //获取App 的分类
  $type = explode('http://www.likecs.com/',$type);
  $info['category'] = end($type); $creative = $dom->find('[data-screenshot-item-index] img'); //获取App 的素材
$info['screenshot'] = [];
foreach($creative as $item){
$info['screenshot'][]=["url"=>$item->getAttr('src')];
}
response()->json($info);

}

写在最后,以上就是PHP 通过一个包名获取goole store paly素材的操作,如果想拿到更多的信息,可以观察goole store paly某一个App页面得出。

*转载请务必注明来源

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zyddwg.html