3
5

More than 5 years have passed since last update.

楽天APIでランキングを取得する

Last updated at Posted at 2015-03-19

inputでカテゴリーIDを入力して楽天ランキング30位までを取得するスクリプト。
今後色々遊んで見るための覚書程度。

rakuapi.py

#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
import requests
import sys, codecs
sys.stdout = codecs.getwriter("utf-8")(sys.stdout)

gen_input = input("catID input here: ")

url = "https://app.rakuten.co.jp/services/api/IchibaItem/Ranking/20120927?"

st_load = {
    "genreId": gen_input,
    "applicationId": [your id],
    }

r = requests.get(url, params=st_load)

res = r.json()

for i in res["Items"]:
    item = i["Item"]
    print u"順位: ",item["rank"],u"位"
    print u"商品名: ",item["itemName"]
    print u"URL: ",item["itemUrl"]
    print u"価格: ",item["itemPrice"], u"円", "\n"
3
5
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
3
5