def categoryInfo(opts): api = shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, warnings=True) api.execute('GetCategoryInfo', {"CategoryID": 3410}) dump(api, full=False)
def using_attributes(opts): api = shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, warnings=True) api.execute('FindProducts', { "ProductID": {'@attrs': {'type': 'ISBN'}, '#text': '0596154488'}}) dump(api, full=False)
def with_affiliate_info(opts): api = shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, warnings=True, trackingid=1234, trackingpartnercode=9) mySearch = { "MaxKeywords": 10, "QueryKeywords": 'shirt', } api.execute('FindPopularSearches', mySearch) dump(api, full=False)
def popularSearches(opts): api = shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, warnings=True) choice = True while choice: choice = input('Search: ') if choice == 'quit': break mySearch = { # "CategoryID": " string ", # "IncludeChildCategories": " boolean ", "MaxKeywords": 10, "QueryKeywords": choice, } api.execute('FindPopularSearches', mySearch) #dump(api, full=True) print("Related: %s" % api.response_dict().PopularSearchResult.RelatedSearches) for term in api.response_dict( ).PopularSearchResult.AlternativeSearches.split(';')[:3]: api.execute('FindPopularItems', { 'QueryKeywords': term, 'MaxEntries': 3 }) print("Term: %s" % term) try: for item in api.response_dict().ItemArray.Item: print(item.Title) except AttributeError: pass # dump(api) print("\n")
def getSingleItem(itemNumber): ## Create API object api = shopping(debug=False, appid=APPID, config_file='ebay.yaml',certid=CERTID, devid=DEVID) ## Define args for API call. Change TextDescription to Description for full HTML description args = {'ItemID':str(itemNumber), 'IncludeSelector':'TextDescription,ItemSpecifics,Details,ShippingCosts', 'outputSelector':'AspectHistogram'} ## Make API call api.execute('GetSingleItem', args) ## Return XML String return api.response_content()
def popularSearches(opts): api = shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, warnings=True) choice = True while choice: choice = input('Search: ') if choice == 'quit': break mySearch = { # "CategoryID": " string ", # "IncludeChildCategories": " boolean ", "MaxKeywords": 10, "QueryKeywords": choice, } api.execute('FindPopularSearches', mySearch) #dump(api, full=True) print("Related: %s" % api.response_dict().PopularSearchResult.RelatedSearches) for term in api.response_dict().PopularSearchResult.AlternativeSearches.split(';')[:3]: api.execute('FindPopularItems', {'QueryKeywords': term, 'MaxEntries': 3}) print("Term: %s" % term) try: for item in api.response_dict().ItemArray.Item: print(item.Title) except AttributeError: pass # dump(api) print("\n")
def run(opts): api = shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml) api.execute('FindPopularItems', {'QueryKeywords': 'Python'}) print "Shopping samples for SDK version %s" % ebaysdk.get_version() if api.error(): raise Exception(api.error()) if api.response_content(): print "Call Success: %s in length" % len(api.response_content()) print "Response code: %s" % api.response_code() print "Response DOM: %s" % api.response_dom() dictstr = "%s" % api.response_dict() print "Response dictionary: %s..." % dictstr[:50] print "Matching Titles:" for item in api.response_dict().ItemArray.Item: print item.Title
def run(opts): api = shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, warnings=True) api.execute('FindPopularItems', {'QueryKeywords': 'Python'}) print "Shopping samples for SDK version %s" % ebaysdk.get_version() if api.error(): raise Exception(api.error()) if api.response_content(): print "Call Success: %s in length" % len(api.response_content()) print "Response code: %s" % api.response_code() print "Response DOM: %s" % api.response_dom() dictstr = "%s" % api.response_dict() print "Response dictionary: %s..." % dictstr[:50] print "Matching Titles:" for item in api.response_dict().ItemArray.Item: print item.Title
def __init__(self, **kwargs): """ Initialization method. Parameters ---------- sandbox : boolean see Ebay class Returns ------- New instance of :class:`Shopping` : Shopping Examples -------- >>> shopping = Shopping(sandbox=True) >>> shopping #doctest: +ELLIPSIS <app.api.Shopping object at 0x...> >>> shopping.kwargs['domain'] 'open.api.sandbox.ebay.com' >>> shopping = Shopping(sandbox=False) >>> shopping.kwargs['domain'] 'open.api.ebay.com' """ super(Shopping, self).__init__(**kwargs) domain = 'open.api.sandbox.ebay.com' if self.sandbox else 'open.api.ebay.com' new = { 'siteid': self.global_ids[self.kwargs['country']]['countryid'], 'domain': domain, 'uri': '/shopping', 'version': '873', 'compatibility': '873', } self.kwargs.update(new) self.api = shopping(**self.kwargs)
from codecs import getwriter from sys import argv, stdout from ebaysdk import finding from ebaysdk import shopping import json import os.path home_dir = os.path.expanduser("~") with open(os.path.join(home_dir, 'ApiKeys/EbayKey.json')) as key_file: keys = json.load(key_file) MEM_CATEGORY = 170083 CPU_CATEGORY = 164 COMPUTER_PARTS_CATEGORY = 175673 UTF8Writer = getwriter('utf8') stdout = UTF8Writer(stdout) myAppId = keys['AppId'] apiFinding = finding(appid=myAppId) apiShopping = shopping(appid=myAppId)
def processItem(item): imageURL = item['galleryURL']['value'] ebayItemId =item['itemId']['value'] itemName =item['title']['value'] logging.info(pprint.pformat(item)) pprint.pprint("ItemID:" + ebayItemId ) pprint.pprint("Title:" + itemName ) pprint.pprint("Gallery URL:" + imageURL) storePicture(itemName, imageURL, getBaseFileName(item)+"-gallery.jpg") processLargePicture(item) api = shopping(appid=EBAY_APP_ID, debug=True) logging.info("Search Tearms: " + ebaySearchTerms ) # api.execute('findItemsAdvanced', # {'keywords': ebaySearchTerms, # 'outputSelector':['PictureURLSuperSize']}) api.execute('horseshit', {'ItemId': '321403054026'}) output = api.response_dict();
import numpy, pprint from datetime import datetime, timedelta import ConfigParser import os DIR = os.path.dirname(os.path.realpath(__file__)) config = ConfigParser.RawConfigParser() config.read(os.path.join(DIR,'config.cfg')) unwantedConditions = ['For parts or not working'] app = Flask(__name__) app.debug = True appid = config.get('Ebay','appid') api = finding(appid=appid) api2 = shopping(appid=appid) @app.route('/') def index(): return render_template('index.html') @app.route('/findCategory', methods = ['POST']) @app.route('/findCategory/<searchTerm>') @app.route('/findCategory/<searchTerm>/<categoryId>') def findCategory(searchTerm=None, categoryId=None): if searchTerm is None: searchTerm = request.form['searchTerm'] params = { 'itemFilter': [ {'name': 'Condition', 'value': 'Used'}, #{'name': 'SoldItemsOnly', 'value': True}
}) return api.response_dict() trade = trading(domain='api.sandbox.ebay.com', appid="MatthewB-33a9-4d50-b56e-4398cece88d6", devid="41d63e06-0775-4692-b656-896a9a4b39d8", certid="5707a4f4-912d-4154-ac6e-d59ec72d3e75", token="AgAAAA**AQAAAA**aAAAAA**wtLjUg**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wFk4GhC5iCowudj6x9nY+seQ**a4ECAA**AAMAAA**bz7sLZhXIMpFSPQQ/Jjkj8XQLJ5IeP/mLRf5oCVeXBmeX91trkLKBR9adYukIDIBwqpT+RxJwGBcdY8DiOu2Va3CWquDpDcGr32NrjS3tlDJp4z09e5vvJChiWD4jAlVgu0NVZKKOSMO/Uc5rYuZQQO0JPdTGbg+r4Lut7JwVJL5IthVTTv7Ec/53E0CAbjVGFBcWvquyeLJ4GUH5sNJM7a0yeNLIv8k4O8x+Aas3igY4LfLaDAOwziFrO83+7UHU9cyf4juHhxPTPvRhGvMdBwFJihLosQ7OPh8HNOecRnnm1cK5cziwjQCqGSJJpK9fB/7EtpKOK015Et2tHF18TWyYkSrbq7TPNoGVE7kAOLK8Q/dEEdlTyJrSq4gM/aBKKHzMwkTyYfzY0Fn+/wRTz6IlExWt6NLjJf6ByzZzk7jgh98VxQMgnYxaPyZ1sNlCuLaTbt2Ui866kIZsSJr7beY2cn6+58/cZuLaJgJoaYAtW526VUGSIHB1RE88cuXfafBgeviqjC6TDUVu1w9KGdGlQFPj38RFXXDbCriIe6P1jDtdl4vt02w9uVPWBDqxnVB+7q+N6sYSrMymhMHKXNr47y06drZdAqw3/ZCx2UMdMGYjyNjbZCg7LJUx5ZRCUPgJSPFSyaTv6c8viu8LLYwaH/QSKGpC8gFkGPqbvC1zUoq5E8H26NyKAO4+9ZqFnTqZxFAv82Ik94ybqGUYkC6TSBqvEBV/OC435/sVZZ+4+/GGCfCMPCuM2AlcvqM") merch = merchandising(domain='svcs.sandbox.ebay.com', appid='MatthewB-33a9-4d50-b56e-4398cece88d6') find = finding(domain='svcs.sandbox.ebay.com', appid='MatthewB-33a9-4d50-b56e-4398cece88d6') shop = shopping(domain='open.api.sandbox.ebay.com', appid='MatthewB-33a9-4d50-b56e-4398cece88d6') #pprint.pprint(get_categories(trade)) top_selling_products = get_top_selling_products(246, find) pprint.pprint(top_selling_products) for product in top_selling_products.productRecommendations.product: print('Aggregating data for {0} ({1})'.format(product.title, product.productId.value)) item_ids = [] product_items = get_product_items(product.productId.value, shop) if product_items and product_items.ItemArray: for item in product_items.ItemArray.Item: pprint.pprint(item) if not isinstance(item, basestring): pprint.pprint(get_single_item(item.ItemID, shop).Item) #db.items.save(get_single_item(item.ItemID, shop).Item) # pprint.pprint(item)