Hit the Rakuten Ranking API to save the ranking of any category in CSV

Hit the Rakuten Ranking API, A script that saves ranking, product name, URL, and price in CSV.

By entering any category ID You can get the category ranking you want to get. I think it can be used when you want to collect data based on some Rakuten ranking.

rakutenrank.py



#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import csv
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": ******************************,
    }

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

res = r.json()

f = open("raku.csv" , "ab")
writer = csv.writer(f)
writer.writerow(["No", "Itemname", "URL", "Price"])

for i in res["Items"]:
	item = i["Item"]
	Rank = item["rank"]
	Name = (item["itemName"].encode("utf-8"))
	Url = item["itemUrl"]
	Price = item["itemPrice"]
	
	writer.writerow([Rank, Name, Url, Price])
	
f.close()

Recommended Posts

Hit the Rakuten Ranking API to save the ranking of any category in CSV
Hit the Sesami API in Python
Hit the web API in Python
An easy way to hit the Amazon Product API in Python
Hit the New Relic API in Python to get the server status
Python beginners hit the unofficial API of Google Play Music to play music
Various ways to read the last line of a csv file in Python
I tried to touch the API of ebay
Hit the Firebase Dynamic Links API in Python
Save the search results on Twitter to CSV.
How to limit the API to be published in the C language shared library of Linux
How to hit the document of Magic Function (Line Magic)
To do the equivalent of Ruby's ObjectSpace._id2ref in Python
How to calculate the sum or average of time series csv data in an instant
Scraping the member stores of Go To EAT in Osaka Prefecture and converting them to CSV
How to find the optimal number of clusters in k-means
Batch convert all xlsx files in the folder to CSV files
An introduction to the modern socket API to learn in C
Keras I want to get the output of any layer !!
Django Changed to save lots of data in one go
Output product information to csv using Rakuten product search API [Python]
How to get rid of the "Tags must be an array of hashes." Error in the qiita api
Scraping the list of Go To EAT member stores in Fukuoka prefecture and converting it to CSV
Scraping the list of Go To EAT member stores in Niigata prefecture and converting it to CSV
Convert PDF of the progress of the division of labor (trends in insurance dispensing) of the Japan Pharmaceutical Association to CSV
Hit Mastodon's API in Python
Get ranking with Rakuten API
How to handle multiple versions of CUDA in the same environment
Save the results of crawling with Scrapy to the Google Data Store
How to determine the existence of a selenium element in Python
How to know the internal structure of an object in Python
[Python] PCA scratch in the example of "Introduction to multivariate analysis"
How to change the color of just the button pressed in Tkinter
[Cloudian # 9] Try to display the metadata of the object in Python (boto3)
Hit the echo command in the Mac terminal to output Hello World
How to check the memory size of a variable in Python
Output the contents of ~ .xlsx in the folder to HTML with Python
Feel free to change the label of the legend in Seaborn in python
Use PyCaret to predict the price of pre-owned apartments in Tokyo!
I wrote the code to write the code of Brainf * ck in python
How to check the memory size of a dictionary in Python
[TensorFlow 2] How to check the contents of Tensor in graph mode
Try to model the cumulative return of rollovers in futures trading
When you want to save the result of the callback function somewhere
How to get the vertex coordinates of a feature in ArcPy
About the SystemChannels API to take advantage of Flutter platform-specific features
Regularly upload files to Google Drive using the Google Drive API in Python
Create a function to get the contents of the database in Go
I want to know the population of each country in the world.
Try to predict the triplet of boat race by ranking learning
I want to be healed by Mia Nanasawa's image. In such a case, hit the Twitter API ♪
Use Cloud Dataflow to dynamically change the destination according to the value of the data and save it in GCS