23
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

特定アプリのapp storeでのランキングを取得する

Posted at

アプリのランキングを取得するスクリプトを書いてみました。

<?php

$targetAppIds = array(
  'id834802911',
  'id443904275',
);

$feed = file_get_contents('https://itunes.apple.com/jp/rss/topfreeapplications/limit=100/xml');
$rss = simplexml_load_string($feed);

$result = array();

foreach($rss->entry as $val) {
    $ranking++;

    $title = $val->title;
    $url   = $val->id;

    foreach ($targetAppIds as $targetUrl) {
	if (strpos($url, $targetUrl) !== false) {
	    $result[] = array(
	        'app_name' => (string)$title,
	        'ranking' => $ranking);
	}
    }
}

foreach ($result as $val) {
    echo sprintf("【%s位】%s\n", $val['ranking'], $val['app_name']);
}
23
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?