red-eagle / google-play-scraper
一个用于从Google Play获取应用数据的PHP爬虫。是raulr/google-play-scraper的分支。
该软件包的规范存储库似乎已消失,因此该软件包已被冻结。
Requires
- fabpot/goutte: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^1.10
- mockery/mockery: ^0.9.4
- phpunit/phpunit: ^4.0
This package is not auto-updated.
Last update: 2024-01-09 00:29:37 UTC
README
由https://github.com/undefinedor/google-play-scraper合并https://github.com/raulr/google-play-scraper
一个用于从Google Play获取应用数据的PHP爬虫。
安装
将red-eagle/google-play-scraper
添加到你的composer.json
文件中的require依赖项
$ composer require red-eagle/google-play-scraper
用法
首先创建一个Scraper
实例。
use Raulr\GooglePlayScraper\Scraper; $scraper = new Scraper();
有几种方法可以配置默认行为
setDelay($delay)
:设置请求Google Play网站之间的延迟(以毫秒为单位)。setDefaultLang($lang)
:设置所有请求的默认语言。$lang
必须是一个ISO_639-1两位字母的语言代码。如果未设置,则默认语言为en
。setDefaultCountry($country)
:设置所有请求的默认国家。$country
必须是一个ISO_3166-1两位字母的国家代码。如果未设置,则默认国家为us
。
getApp
根据ID获取应用信息。
参数
$id
:Google Play应用标识符。$lang
:(可选,默认为null
):覆盖默认语言。$country
:(可选,默认为null
):覆盖默认国家。
示例
$app = $scraper->getApp('com.mojang.minecraftpe');
返回
array ( 'id' => 'com.mojang.minecraftpe', 'url' => 'https://play.google.com/store/apps/details?id=com.mojang.minecraftpe', 'image' => 'https://lh3.googleusercontent.com/30koN0eGl-LHqvUZrCj9HT4qVPQdvN508p2wuhaWUnqKeCp6nrs9QW8v6IVGvGNauA=w300', 'title' => 'Minecraft: Pocket Edition', 'author' => 'Mojang', 'author_link' => 'https://play.google.com/store/apps/developer?id=Mojang', 'categories' => array ( 'Arcade', 'Creativity', ), 'price' => '$6.99', 'screenshots' => array ( 'https://lh3.googleusercontent.com/VkLE0e0EDuRID6jdTE97cC8BomcDReJtZOem9Jlb14jw9O7ytAGvE-2pLqvoSJ7w3IdK=h310', 'https://lh3.googleusercontent.com/28b1vxJQe916wOaSVB4CmcnDujk8M2SNaCwqtQ4cUS0wYKYn9kCYeqxX0uyI2X-nQv0=h310', // [...] ), 'description' => 'Our latest free update includes the Nether and all its inhabitants[...]', 'description_html' => 'Our latest free update includes the Nether and all its inhabitants[...]', 'rating' => 4.4726405143737793, 'votes' => 1136962, 'last_updated' => 'October 22, 2015', 'size' => 'Varies with device', 'downloads' => '10,000,000 - 50,000,000', 'version' => 'Varies with device', 'supported_os' => 'Varies with device', 'content_rating' => 'Everyone 10+', 'whatsnew' => 'Build, explore and survive on the go with Minecraft: Pocket Edition[...]', 'video_link' => 'https://www.youtube.com/embed/D2Z9oKTzzrM?ps=play&vq=large&rel=0&autohide=1&showinfo=0&autoplay=1', 'video_image' => 'https://i.ytimg.com/vi/D2Z9oKTzzrM/hqdefault.jpg', )
以下字段可能包含一个null
值:price
、size
、downloads
、version
、whatsnew
、video_link
和video_image
。当price
为null
时,表示该应用免费。
getApps
根据ID获取多个应用的信息。
参数
$ids
:Google Play应用标识符数组。$lang
:(可选,默认为null
):覆盖默认语言。$country
:(可选,默认为null
):覆盖默认国家。
示例
$app = $scraper->getApps(array( 'com.mojang.minecraftpe', 'com.google.android.youtube', ));
getCategories
返回一个包含Google Play现有分类的数组。
示例
use Raulr\GooglePlayScraper\Scraper; $scraper = new Scraper(); $categories = $scraper->getCategories();
返回
array ( 'BOOKS_AND_REFERENCE', 'BUSINESS', 'COMICS', 'COMMUNICATION', 'EDUCATION', 'ENTERTAINMENT', 'FINANCE', 'HEALTH_AND_FITNESS', 'LIBRARIES_AND_DEMO', 'LIFESTYLE', 'APP_WALLPAPER', 'MEDIA_AND_VIDEO', 'MEDICAL', 'MUSIC_AND_AUDIO', 'NEWS_AND_MAGAZINES', 'PERSONALIZATION', 'PHOTOGRAPHY', 'PRODUCTIVITY', 'SHOPPING', 'SOCIAL', 'SPORTS', 'TOOLS', 'TRANSPORTATION', 'TRAVEL_AND_LOCAL', 'WEATHER', 'APP_WIDGETS', 'GAME_ACTION', 'GAME_ADVENTURE', 'GAME_ARCADE', 'GAME_BOARD', 'GAME_CARD', 'GAME_CASINO', 'GAME_CASUAL', 'GAME_EDUCATIONAL', 'GAME_MUSIC', 'GAME_PUZZLE', 'GAME_RACING', 'GAME_ROLE_PLAYING', 'GAME_SIMULATION', 'GAME_SPORTS', 'GAME_STRATEGY', 'GAME_TRIVIA', 'GAME_WORD', 'FAMILY', 'FAMILY_ACTION', 'FAMILY_BRAINGAMES', 'FAMILY_CREATE', 'FAMILY_EDUCATION', 'FAMILY_MUSICVIDEO', 'FAMILY_PRETEND', )
getCollections
返回一个包含Google Play现有收藏夹的数组。
示例
$collections = $scraper->getCollections();
返回
array ( 'topselling_free', 'topselling_paid', 'topselling_new_free', 'topselling_new_paid', 'topgrossing', 'movers_shakers', )
getList
根据收藏夹获取Google Play应用列表,并可选择按分类过滤。
参数
$collection
: 要检索的 Google Play 收集。有关可能的值,请参阅 getCollections。$category
: (可选,默认为null
)通过此类别过滤请求。有关可能的值,请参阅 getCategories。$lang
:(可选,默认为null
):覆盖默认语言。$country
:(可选,默认为null
):覆盖默认国家。
示例
$apps = $scraper->getList('topselling_free', 'SOCIAL');
返回
array ( array ( 'id' => 'com.facebook.katana', 'url' => 'https://play.google.com/store/apps/details?id=com.facebook.katana', 'title' => 'Facebook', 'image' => 'https://lh3.googleusercontent.com/ZZPdzvlpK9r_Df9C3M7j1rNRi7hhHRvPhlklJ3lfi5jk86Jd1s0Y5wcQ1QgbVaAP5Q=w340', 'author' => 'Facebook', 'rating' => 3.9888803958892822, 'price' => null, ), array ( 'id' => 'com.snapchat.android', 'url' => 'https://play.google.com/store/apps/details?id=com.snapchat.android', 'title' => 'Snapchat', 'image' => 'https://lh4.ggpht.com/vdK_CsMSsJoYvJpYgaj91fiJ1T8rnSHHbXL0Em378kQaaf_BGyvUek2aU9z2qbxJCAFV=w340', 'author' => 'Snapchat Inc', 'rating' => 3.8660063743591309, 'price' => null, ), // [...] )
getDetailList
与 getList 相同,但返回完整的详细应用数据。为了获取每个应用的信息,将向列表中的每个应用发出额外的请求。
getListChunk
检索 Google Play 应用列表的一部分。
参数
$collection
: 要检索的 Google Play 收集。有关可能的值,请参阅 getCollections。$category
: (可选,默认为null
)通过此类别过滤请求。有关可能的值,请参阅 getCategories。$start
: (可选,默认为0
):起始索引。必须是介于0
和500
之间的值。$num
: (可选,默认为60
):要检索的应用数量。必须是介于0
和120
之间的值。$lang
:(可选,默认为null
):覆盖默认语言。$country
:(可选,默认为null
):覆盖默认国家。
示例
$apps = $scraper->getListChunk('topselling_free', 'SOCIAL', 20, 80);
getDetailListChunk
与 getListChunk 相同,但返回完整的详细应用数据。为了获取每个应用的信息,将向搜索结果列表中的每个应用发出额外的请求。
getSearch
根据搜索查询检索 Google Play 应用列表,并可按价格和评分进行过滤。
参数
$query
: 搜索查询。$price
: (可选,默认为all
)按价格过滤请求。可能的值:all
、free
、paid
。$rating
: (可选,默认为all
)按评分过滤请求。可能的值:all
、4+
。$lang
:(可选,默认为null
):覆盖默认语言。$country
:(可选,默认为null
):覆盖默认国家。
示例
$apps = $scraper->getSearch('unicorns', 'free', '4+');
getDetailSearch
与 getSearch 相同,但返回完整的详细应用数据。为了获取每个应用的信息,将向搜索结果列表中的每个应用发出额外的请求。
getCommentCount
检索选定语言的应用的评论数量。
参数
$id
- 应用 Google Play ID$lang
- 语言
示例
$commentCount = $scraper->getCommentCount('com.facebook.katana', 'en');
getAllLangCommentCount
与 getCommentCount 相同,但检索所有选定语言的评论数量(作为第二个参数的数组)
参数
$id
- 应用 Google Play ID$langs
- 语言(数组)
getSimilar
检索类似的应用
参数
$id
- 应用 Google Play ID
getDetailSimilar
与getDetailSimilar相同,但检索包含详细信息的应用程序
$id
- 应用 Google Play ID