【发布时间】:2017-03-11 06:28:47
【问题描述】:
我正在尝试从 iTunes 应用程序 url 获取图标和屏幕截图图像。但是我只能获取特定应用程序的屏幕截图。如果是图标,我会为所有应用程序获取以下 URL https://s.mzstatic.com/htmlResources/ef35/frameworks/images/p.png。如果是 google play,我可以同时获取图标和屏幕截图。iTunes 是否限制图标图像的获取或者我的代码中有错误?
<?php
// Report all PHP errors (see changelog)
error_reporting(E_ALL);
include('simplehtmldom_1_5/simple_html_dom.php');
//base url
$base = "https://itunes.apple.com/cn/app/kindle/id405399194?mt=12&ign-mpt=uo%3D2";
if (strpos($base, 'play.google.com') !== false) {
$html_base = file_get_html( $base );
$icon = "https:".$html_base->find('div[class=details-info] img[class=cover-image]')[0]->src;
echo $icon."<br>";
$screenShot = "https:".$html_base->find('div[class=screenshot-align-inner] img')[0]->src;
echo $screenShot;
}elseif (strpos($base,'itunes.apple.com') !== false) {
$html_base = file_get_html( $base );
$icon = $html_base->find('div[class=artwork] img')[4]->src;
echo $icon."<br>";
$screenShot = $html_base->find('div[class=lockup] img')[0]->src;
echo $screenShot;
}
$html_base->clear();
unset($html_base);?>
【问题讨论】:
标签: php html-parsing itunes simple-html-dom