<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>英語多読 - イチゾーのブログ</title>
	<atom:link href="https://ichizo.biz/tag/%E8%8B%B1%E8%AA%9E%E5%A4%9A%E8%AA%AD/feed" rel="self" type="application/rss+xml" />
	<link>https://ichizo.biz</link>
	<description>システム開発やWordPressについてなど</description>
	<lastBuildDate>Thu, 29 Dec 2016 08:25:19 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
<site xmlns="com-wordpress:feed-additions:1">120380898</site>	<item>
		<title>PythonでAmazon Product Advertising APIを呼び出してKindle Unlimitedの情報を取得する</title>
		<link>https://ichizo.biz/2016/12/29/kindle-unlimited.html</link>
					<comments>https://ichizo.biz/2016/12/29/kindle-unlimited.html?noamp=mobile#respond</comments>
		
		<dc:creator><![CDATA[一蔵]]></dc:creator>
		<pubDate>Thu, 29 Dec 2016 08:25:19 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[英語]]></category>
		<category><![CDATA[Amazon Product Advertising API]]></category>
		<category><![CDATA[英語多読]]></category>
		<guid isPermaLink="false">http://ichizo.biz/?p=100</guid>

					<description><![CDATA[<p>「英語多読用の本をレベル別に取得する（完成版）」で、 英語多 [&#8230;]</p>
<p>The post <a href="https://ichizo.biz/2016/12/29/kindle-unlimited.html">PythonでAmazon Product Advertising APIを呼び出してKindle Unlimitedの情報を取得する</a> first appeared on <a href="https://ichizo.biz">イチゾーのブログ</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>「<a href="http://ichizo.biz/2016/12/29/python-selenium-3.html">英語多読用の本をレベル別に取得する（完成版）</a>」で、<br />
英語多読用の本のISBNリストを取得しました。</p>
<p>今度はこれを使用して、Amazon Product Advertising APIを呼び出してKindle Unlimitedの情報を取得するということをやります。</p>
<h2>目的：英語多読をKindle Unlimitedでやりたい</h2>
<p>英語力を伸ばしたいということで、英語多読をやってみたいのですが、<br />
多読用の本を買っていては高くついてしまうというネックがあります。</p>
<p><a href="https://www.seg.co.jp/sss/learning/sss-for-low-intermeidate.html" target="_blank">英語多読研究会さんのHP</a>に、難易度別の類型読書語数の目安が掲載されています。</p>
<p>それによると、各レベルごとの累計語数は以下のようになっています。</p>
<pre>
Level0　　 30,000語
Level1　　120,000語
Level2　　470,000語
Level3　1,020,000語
Level4　1,320,000語
Level5　1,600,000語
Level6　1,900,000語
Level7　2,000,000語
Level8　2,200,000語
Level9　2,380,000語
</pre>
<p>これを達成するためには、各レベルで以下の冊数が必要になります。</p>
<pre>
Level0　30冊
Level1　30冊
Level2　50冊
Level3　50冊
Level4　15冊
Level5　10冊
Level6　10冊
Level7　2冊
Level8　2冊
Level9　1冊
</pre>
<p>Level0では、3万語の読書語数が推奨されていますが、<br />
これを満たすためには大体30冊読まなければいけないという計算になります。</p>
<p>Level9では、読書語数は18万語となっていますが、<br />
読むべき冊数は1冊です。</p>
<p>これは、難易度があがると1冊あたりの語数が増えるため、<br />
読む必要がある冊数は減ってくるということですね。</p>
<p>英語多読を始めたばかりの難易度の低い頃に読むのが<br />
語数が少なく読みやすい本（児童向けだったりします）になりますので、<br />
必然的に読むべき冊数が増えてしまいます。</p>
<p>１冊あたり500円とか600円とかなので、決して高いわけではありませんが、<br />
Level0で30冊、Level1で30冊、Level2で50冊・・・<br />
となると、一人で揃えるには予算的に非常に厳しいものがあります。</p>
<p>そこで、読み放題のKindle Unlimitedを英語多読に使えないかと考えた訳です。</p>
<p>英語多読研究会さんでは、<a href="http://www.seg.co.jp/sss_review/jsp/frm_a_100.jsp" target="_blank">多読用の洋書のリストを難易度別に公開されています</a>ので、<br />
ここで公開されている本のリストから、Kindle Unlimitedに登録されているものを探し出すということをやってみます。</p>
<p>多読用の本のリスト取得は<a href="http://ichizo.biz/2016/12/29/python-selenium-3.html">前回</a>までに行っていますので、<br />
今回は取得したリストを元にAmazon Product Advertising APIを呼び出して本の情報を取得するということをやってみます。</p>
<p>ソースコード</p>
<pre class="lang:python decode:true " title="amazon_api.py" >
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 19 14:49:19 2016

@author: 
"""

from bottlenose import api
from lxml import objectify
import time

AMAZON_ACCESS_KEY_ID = "アクセスキー"
AMAZON_SECRET_KEY = "シークレットキー"
AMAZON_ASSOC_TAG = "アソシエイトタグ"

KINDLE_UMLIMITED_NODE_ID = "4486610051"

amazon = api.Amazon(AMAZON_ACCESS_KEY_ID, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG, Region = "JP")

def file_read (file):
    f = open(file, 'r')
    data = f.read()
    f.close()
    lines = data.split('\n')
    return lines

def loop_min(max_level):
    book_list = []
    min_level = 0
    while min_level &lt; 1:
        level = max_level + min_level
        print('list'+str('%1.1f' % level)+'.txt')
        lines = file_read('list'+str('%1.1f' % level)+'.txt')
        for line in lines:
            if (len(line) &gt; 0):
                print('line='+line)
                items = item_search(line)
                item_find = items.find('Item')
                if (item_find is not None):
                    for item in item_find:
                        if (item is not None):
                            title = item.ItemAttributes.Title
                            author = item.ItemAttributes.Author
                            isbn = item.ItemAttributes.Isbn
                            url = item.DetailPageURL
                            print(("%s, %s, %s, %s, %s" % (line, title, author, isbn, url)))
                            book_list.append(str("%s, %s, %s, %s, %s" % (line, title, author, isbn, url)))
                        else:
                            print ("%s : Book is None" % (line))
                #print ("END %s" % (line))
                time.sleep(5)   # Amazon API呼び出しは1秒に1回以内に収めるためsleep

        min_level += 0.1
        
    return book_list
    
def loop_max():
    max_level = 0
    while max_level &lt; 10:
        book_list = loop_min(max_level)
        write_file(book_list, max_level)
        max_level += 1
    
def write_file(book_list, max_level):
    f = open('amazon'+str('%1d' % max_level)+'.txt', 'w')
    for book in book_list:
        f.write(book)
        f.write('\n')
    f.close()

def item_search (keywords, searchIndex="KindleStore", browseNode=KINDLE_UMLIMITED_NODE_ID):
    response = amazon.ItemSearch(Keywords=keywords, SearchIndex=searchIndex, BrowseNode=browseNode, ResponseGroup="Large")
    root = objectify.fromstring(response)
    return root.Items

if __name__ == '__main__':
    
        loop_max()
</pre>
<p>bottlenoseを使ってAmazon Product Advertising APIを呼び出しています。</p>
<p>この使い方は<a href="http://ichizo.biz/2016/12/20/english-kindle-unlimited.html">以前の記事</a>を参考にしてください。</p>
<p>今回やっていることは、ISBNのリストファイルを開き１行ずつAmazon Product Advertising APIで<br />
Kindle Unlimitedの情報を取得するということです。</p>
<p>ループの頻度ですが、Amazon Product Advertising APIには<br />
頻繁にアクセスするとエラーを返す仕様がある（1秒間に1回以内に抑える）ので<br />
sleepを5秒入れています。</p>
<p>これで実行していたのですが、<br />
「接続済みの呼び出し先が一定の時間を過ぎても正しく応答しなかったため、接続できませんでした。または接続済みのホストが応答しなかったため、確立された接続は失敗しました。」<br />
というエラーが返ってきて中断しましたので、sleep 10秒で再トライしてみます。</p>
<p>英語多読で使えるKindle Unlimitedの本のリストはまとめて公開したいと思います。</p><p>The post <a href="https://ichizo.biz/2016/12/29/kindle-unlimited.html">PythonでAmazon Product Advertising APIを呼び出してKindle Unlimitedの情報を取得する</a> first appeared on <a href="https://ichizo.biz">イチゾーのブログ</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://ichizo.biz/2016/12/29/kindle-unlimited.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">100</post-id>	</item>
	</channel>
</rss>
