2016-10-28 6 views
1

iTunesのアプリのURLからアイコンやスクリーンショットの画像を取得しようとしていますが、特定のアプリのスクリーンショットしか取得できません。アイコンの場合、私はすべてのアプリのために次のURLをhttps://s.mzstatic.com/htmlResources/ef35/frameworks/images/p.pngに取得します.Googleの再生の場合アイコンとスクリーンショットの両方を取得できます。 itunesはアイコン画像の取得を制限するか、コードにエラーがありますか?SimpleHTMLDOMパーサーを使用して、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);?> 

答えて

1

srcが実際の画像のパスを取得しないので問題はSRC-スワップの代わりにSRCを使用することによって解決しました。

}elseif (strpos($base,'itunes.apple.com') !== false) { 

$html_base = file_get_html($base); 
$icon = $html_base->find('div[class=artwork] img')[4]->{'src-swap'}; 
//the main icon for itunes is atleast 175px 
echo $icon."<br>"; 
$screenShot = $html_base->find('div[class=lockup] img')[0]->src; 
echo $screenShot; 
} 
関連する問題