Ejemplo n.º 1
0
__author__ = 'ACC53-1'
import os
import configparser, time
from myutil import myutil
from mws import mws
root_path = os.path.abspath('..')
root_path = root_path.replace('\\', '/')
config_path = myutil.get_path(root_path, ['app', 'config']) + 'config.ini'
config = configparser.ConfigParser()
config.read(config_path)
access_key = config.get('mws', 'mws_access_key')
secret_key = config.get('mws', 'mws_secret_key')
account_id = config.get('mws', 'seller_id')
market_place_id = config.get('mws', 'market_place_id')
region = config.get('mws', 'region').upper()
print(access_key, secret_key)
product_client = mws.Products(access_key, secret_key, account_id, region)
asins = [
    'B00Z8F00L6', 'B010EVS2BS', 'B009O0HZCI', 'B00FDVMSCE', 'B00MCA5UW4',
    'B00YZLRJJU', 'B00FF0ND9U', 'B00C7GA8SE', 'B00SB2G9OK', 'B010EX3BVM',
    'B011W95MY6', 'B00FG14BLC', 'B00Z8EXTCE', 'B00E6T3O18', 'B00N4JEHPS',
    'B00ZVP8UW4', 'B00ZM398SK', 'B00YTJ1GLA', 'B00IJ0DITI', 'B00YZMNTXE'
]
while True:
    try:
        res = product_client.get_lowest_offer_listings_for_asin(
            market_place_id, asins, 'Any')
        break
    except:
        pass
        time.sleep(10)
Ejemplo n.º 2
0
from myutil import myutil
from product_api import orders
import os
import datetime
start = datetime.datetime.now()
app_path = os.path.split(os.path.abspath(__file__))[0] + '/'
root_path = os.path.abspath(app_path + '../').rstrip('/') + '/'
root_path = root_path.replace('\\', '/')
asin_dir = myutil.get_path(root_path, ['src', 'asins'])
config_dir = myutil.get_path(root_path, ['app', 'config'])
position = int(myutil.get_config_value(root_path, 'aws', 'position'))
mws_access_key = myutil.get_config_value(root_path, 'mws', 'mws_access_key')
mws_secret_key = myutil.get_config_value(root_path, 'mws', 'mws_secret_key')
mws_seller_id = myutil.get_config_value(root_path, 'mws', 'seller_id')
region = myutil.get_config_value(root_path, 'aws', 'region')
orders_client = orders.Orders(mws_access_key, mws_secret_key, mws_seller_id,
                              region)
orderids_list = orders_client.get_orderids("2015-11-01", "2015-11-02")
asins_list = []
if orderids_list:
    for orderid in orderids_list:
        asin = orders_client.get_order_asin(orderid)
        asins_list.append(asin)
print(asins_list)

file_date = datetime.date.today()
#output_file = myutil.get_path(root_path,['src','output'])+'details_'+str(file_date)+'.txt'
Ejemplo n.º 3
0
from myutil import myutil
from product_api import product_api_mws
import os
import datetime
start = datetime.datetime.now()
app_path = os.path.split(os.path.abspath(__file__))[0] + '/'
root_path = os.path.abspath(app_path + '../').rstrip('/') + '/'
root_path = root_path.replace('\\', '/')
asin_dir = myutil.get_path(root_path, ['src', 'asins'])
asins_list = myutil.get_asins_from_asindir(asin_dir)
config_dir = myutil.get_path(root_path, ['app', 'config'])
position = int(myutil.get_config_value(root_path, 'aws', 'position'))
mws_access_key = myutil.get_config_value(root_path, 'mws', 'mws_access_key')
mws_secret_key = myutil.get_config_value(root_path, 'mws', 'mws_secret_key')
mws_seller_id = myutil.get_config_value(root_path, 'mws', 'seller_id')
region = myutil.get_config_value(root_path, 'aws', 'region')
sales_rank_limit = myutil.get_config_value(root_path, 'aws', 'sale_rank_limit')
product_api = product_api_mws.Product_API_MWS(mws_access_key, mws_secret_key,
                                              mws_seller_id, region)
file_date = datetime.date.today()
output_file = myutil.get_path(
    root_path, ['src', 'output']) + 'details_' + str(file_date) + '.txt'
while position < len(asins_list):
    data = product_api.get_product_details(
        myutil.convert_isbn(asins_list[position]), sales_rank_limit)
    #exit()
    if data:
        try:
            myutil.write_to_file(output_file, data)
            #print(data)
        except:
Ejemplo n.º 4
0
__author__ = 'Joseph'
from myutil import myutil
from product_api import product_api
import os
from datetime import datetime
start = datetime.now()
app_path=os.path.split(os.path.abspath(__file__))[0]+'/'
root_path=os.path.abspath(app_path+'../').rstrip('/')+'/'
root_path=root_path.replace('\\','/')
file_name = input('Please input the file name:')
source_asin_dir = myutil.get_path(root_path,['src','source_asins'])
filter_asin_dir = myutil.get_path(root_path,['src','filter_asins'])
source_asins = myutil.get_source_asins_from_asindir(source_asin_dir)
print(len(source_asins))
filter_asins = myutil.get_filter_asins_from_filter_asindir(filter_asin_dir)
print(len(filter_asins))
print('\n')
asins_list = myutil.get_asins(source_asins,filter_asins)
print(len(asins_list))
asin_path = myutil.get_path(root_path,['src','asins_temp'])
myutil.write_to_asinfile(file_name,asin_path,asins_list)
end = datetime.now()
print((end-start).seconds)