Skip to content

Instantly share code, notes, and snippets.

@atton
Last active December 1, 2017 04:31

Revisions

  1. atton revised this gist Dec 1, 2017. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion request.rb
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,4 @@
    require 'amazon/ecs'
    require 'amazon/ecs'
    Amazon::Ecs.configure do |options|
    options[:subscription_id] = options[:AWS_access_key_id] = 'hoge'
    options[:AWS_secret_key] = 'fuga'
  2. atton revised this gist Dec 1, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion kobo.rb
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    API_END_POINT = 'https://app.rakuten.co.jp/services/api/Kobo/EbookSearch/20170426'
    APPLICATION_ID = 'hoge'
    AFFILIATE_ID = 'fuga'1633e485.3da3cbfa.1633e486.309d4714'
    AFFILIATE_ID = 'fuga'

    ElementInformations = ['largeImageUrl', 'title', 'affiliateUrl', 'itemPrice', 'publisherName']

  3. atton revised this gist Dec 1, 2017. 2 changed files with 8 additions and 7 deletions.
    9 changes: 2 additions & 7 deletions fix_request.rb
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,8 @@
    require 'amazon/ecs'
    Amazon::Ecs.configure do |options|
    options[:subscription_id] = options[:AWS_access_key_id] = 'hoge'
    options[:AWS_secret_key] = 'fuga'
    options[:associate_tag] = 'piyo'
    end
    result = Amazon::Ecs.send_request({response_group: 'Images,ItemAttributes,Large',
    operation: 'ItemSearch',
    browse_node: '2293143051',
    minimum_price: 0,
    maximum_price: 0,
    search_index: 'Books'
    marketplace: 'jp'})
    marketplace: 'jp'})
    # return items
    6 changes: 6 additions & 0 deletions request.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,10 @@
    require 'amazon/ecs'
    require 'amazon/ecs'
    Amazon::Ecs.configure do |options|
    options[:subscription_id] = options[:AWS_access_key_id] = 'hoge'
    options[:AWS_secret_key] = 'fuga'
    options[:associate_tag] = 'piyo'
    end
    result = Amazon::Ecs.send_request({response_group: 'Images,ItemAttributes,Large',
    operation: 'ItemSearch',
    browse_node: '2293143051',
  4. atton revised this gist Dec 1, 2017. 2 changed files with 34 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions fix_request.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,9 @@
    require 'amazon/ecs'
    Amazon::Ecs.configure do |options|
    options[:subscription_id] = options[:AWS_access_key_id] = 'hoge'
    options[:AWS_secret_key] = 'fuga'
    options[:associate_tag] = 'piyo'
    end
    result = Amazon::Ecs.send_request({response_group: 'Images,ItemAttributes,Large',
    operation: 'ItemSearch',
    browse_node: '2293143051',
    29 changes: 29 additions & 0 deletions kobo.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    API_END_POINT = 'https://app.rakuten.co.jp/services/api/Kobo/EbookSearch/20170426'
    APPLICATION_ID = 'hoge'
    AFFILIATE_ID = 'fuga'1633e485.3da3cbfa.1633e486.309d4714'
    ElementInformations = ['largeImageUrl', 'title', 'affiliateUrl', 'itemPrice', 'publisherName']
    DefaultOpts = {affiliateId: AFFILIATE_ID,
    applicationId: APPLICATION_ID,
    elements: ElementInformations.join(','),
    formatVersion: 2,
    field: 0,
    hits: 30,
    koboGenreId: 101,
    language: 'JA',
    salesType: 0,
    sort: '+itemPrice'}
    def post hash
    uri = URI.parse(API_END_POINT)
    https = Net::HTTP.new(uri.host, 443)
    https.use_ssl = true
    path = uri.path
    path += '?'
    path += URI.encode_www_form(DefaultOpts.merge(hash))

    request = Net::HTTP::Post.new(path)
    https.request(request)
    end
    post(1) # request 1 page
  5. atton created this gist Nov 30, 2017.
    8 changes: 8 additions & 0 deletions fix_request.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    require 'amazon/ecs'
    result = Amazon::Ecs.send_request({response_group: 'Images,ItemAttributes,Large',
    operation: 'ItemSearch',
    browse_node: '2293143051',
    minimum_price: 0,
    maximum_price: 0,
    search_index: 'Books'
    marketplace: 'jp'})
    7 changes: 7 additions & 0 deletions request.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    require 'amazon/ecs'
    result = Amazon::Ecs.send_request({response_group: 'Images,ItemAttributes,Large',
    operation: 'ItemSearch',
    browse_node: '2293143051',
    minimum_price: 0,
    maximum_price: 0,
    search_index: 'Books'})