Commit 8acb3103 by vulehuan

limit insert only 10000 products

parent 991de60c
...@@ -47,9 +47,8 @@ namespace :db do ...@@ -47,9 +47,8 @@ namespace :db do
# Product list # Product list
# http://developer.yahoo.co.jp/webapi/shopping/shopping/v1/itemsearch.html # http://developer.yahoo.co.jp/webapi/shopping/shopping/v1/itemsearch.html
list_url = 'http://shopping.yahooapis.jp/ShoppingWebService/V1/itemSearch' list_url = 'http://shopping.yahooapis.jp/ShoppingWebService/V1/itemSearch'
i = 0
category_ids.each do |category_id| category_ids.each do |category_id|
i = 0
(1..20).each do |offset| (1..20).each do |offset|
request_url = list_url + '?appid=' + YAHOO_SHOPPING_DATA_APP_ID + '&category_id=' + category_id.to_s + '&offset=' + offset.to_s + '&hits=50' request_url = list_url + '?appid=' + YAHOO_SHOPPING_DATA_APP_ID + '&category_id=' + category_id.to_s + '&offset=' + offset.to_s + '&hits=50'
# get the XML data as a string # get the XML data as a string
...@@ -59,7 +58,7 @@ namespace :db do ...@@ -59,7 +58,7 @@ namespace :db do
doc.elements.each('ResultSet/Result/Hit') do |ele| doc.elements.each('ResultSet/Result/Hit') do |ele|
next if ele.elements['Name'] == nil next if ele.elements['Name'] == nil
i += 1 i += 1
break if i > 2000 break if i > 10000
name = ele.elements['Name'].text name = ele.elements['Name'].text
description = ele.elements['Description'].text description = ele.elements['Description'].text
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment