Exemplo n.º 1
0
def apiCall(keywords, min, max, listing):
    api = Connection(config_file=r'ebay.yaml', debug=True, siteid="EBAY-US")

    request = {
        'keywords':
        keywords,
        'itemFilter': [{
            'name': 'MinPrice',
            'value': min
        }, {
            'name': 'MaxPrice',
            'value': max
        }, {
            'name': 'ListingType',
            'value': listing
        }],
        'paginationInput': {
            'entriesPerPage': 10,
            'pageNumber': 1
        },
        'sortOrder':
        'PricePlusShippingLowest'
    }

    return api.execute('findItemsByKeywords', request)
Exemplo n.º 2
0
 def __init__(self, config):
     self._config = config
     self._client = Connection(domain=self._config['domain'], debug=False,
                               appid=self._config['appid'],
                               config_file=None,
                               siteid=self._config['siteid'])
     self._logger = logging.getLogger(__name__)
Exemplo n.º 3
0
def find_items_on_ebay():
    api = Connection(appid='Balasubr-hacktech-PRD-916e5579d-aa3f3d9b',
                     config_file=None)
    n_items = int(f_request.args.get('n_items'))
    response = api.execute(
        'findItemsAdvanced', {
            'keywords': f_request.args.get('item'),
            'outputSelector': 'SellerInfo',
            'itemFilter': [{
                'name': 'TopRatedSellerOnly',
                'value': 'true'
            }]
        })
    #response = api.execute('GetCharities', {'Query': 'food'})
    assert (response.reply.ack == 'Success')
    assert (type(response.reply.timestamp) == datetime.datetime)
    assert (type(response.reply.searchResult.item) == list)

    item = response.reply.searchResult.item[0]
    assert (type(item.listingInfo.endTime) == datetime.datetime)
    assert (type(response.dict()) == dict)
    result = response.dict()['searchResult']['item'][:10]
    result = sorted(response.dict()['searchResult']['item'][:n_items],
                    key=lambda x: add_shipping_cost(x))
    # print(result)
    return jsonify(result)
Exemplo n.º 4
0
    def __init__(self, id_dict, config):

        self.id_dict = id_dict

        self.err_cnt = 0
        self.tm_last_err = 0
        self.dict_needs_update = 0
        self.crnt_found_items = 0
        self.crnt_srch_key = ''
        self.crnt_srch_type = ''
        self.stats = {}

        self.delay = config['delay']
        self.srch_conf_lst = config['srch']

        self.ids_file = config['ids']
        self.stats_file = config['stats']
        self.err_file = config['errlog']

        self.appid = config['rbt']['appid']
        self.ya_host = config['rbt']['ya_host']
        self.ya_port = config['rbt']['ya_port']
        self.ya_usr = config['rbt']['ya_usr']
        self.ya_pwd = config['rbt']['ya_pwd']
        self.from_email = config['rbt']['from_email']
        self.to_email = config['rbt']['to_email']

        self.api = Connection(appid=self.appid, config_file=None)
    def ProcessQueryEbay(apikey, query):
        try:
            tempList = []
            api = Connection(appid=apikey, config_file=None)
            response = api.execute('findItemsAdvanced', {'keywords': query})

            if hasattr(response.reply.searchResult, 'item'):
                for item in response.reply.searchResult.item:
                    tempDict = {}
                    tempDict[CStaticConsts.siteName] = CStaticConsts.Ebay
                    tempDict[CStaticConsts.title] = item.title
                    tempDict[
                        CStaticConsts.
                        currencyType] = item.sellingStatus.currentPrice._currencyId
                    tempDict[CStaticConsts.
                             itemPrice] = item.sellingStatus.currentPrice.value
                    tempDict[CStaticConsts.productUrl] = item.viewItemURL

                    tempList.append(tempDict)

                return tempList

        except ConnectionError as e:
            print(e)
            print(e.response.dict())
        except Exception as e:
            print('Error: getebaylistings threw exception. Message: ', e)
Exemplo n.º 6
0
def commence_search(card_list, setname, grade):
    for card_name in card_list:
        try:
            api = Connection(appid='vincentc-pokemon-PRD-5f95f0a8e-eb74953b',
                             config_file=None)
            response = api.execute('findItemsByKeywords',
                                   {'keywords': 'mew ex play promo'})

            assert (response.reply.ack == 'Success')
            assert (type(response.reply.timestamp) == datetime.datetime)
            assert (type(response.reply.searchResult.item) == list)
            item = response.reply.searchResult.item

            search_results = response.dict()

            item = response.reply.searchResult.item[0]
            assert (type(item.listingInfo.endTime) == datetime.datetime)
            assert (type(response.dict()) == dict)
            #print (len(k['searchResult']['item']))
            print(search_results['searchResult']['item'][0]['itemId'])

        except ConnectionError as e:

            print(e)
            print(e.response.dict())

    pass
Exemplo n.º 7
0
def call_Ebay_API(page_num, search_keywords, try_count=1):
    try:
        api = Connection(appid='MattDass-FLCompar-PRD-12442a3e5-6825c4fa',
                         config_file=None)
        response = api.execute(
            'findItemsAdvanced', {
                'keywords': search_keywords,
                'paginationInput': {
                    'pageNumber': page_num
                }
            })
        dictstr = api.response.dict()
        df = pd.DataFrame(dictstr)

        # for i in dictstr['searchResult']['item']:
        #     post_JSON_API(i)

        pool = ThreadPool(10)
        pool.map(post_JSON_API, dictstr['searchResult']['item'])

        if page_num <= dictstr['paginationOutput']['totalPages']:
            page_num = page_num + 1
        else:
            page_num = 0
        return page_num
    except Exception as e:
        print e
        if try_count <= 3:
            time.sleep(10)
            try_count += 1
            call_Ebay_API(page_num, try_count)
        else:
            raise ValueError(
                "No luck. Tried connecting 3 times and it still didn't work")
Exemplo n.º 8
0
def ebay_api(search):
	try:
		api = Connection(appid='nyetmoi-zooccs-PRD-ef8fc7c73-6322fe73', config_file=None)
		response = api.execute('findItemsAdvanced', {'keywords': search})
		items = response.reply.searchResult.item
		avg = 0
		cost = 0
		urls = []
		flagged =[]
		for i in range(len(items)):
			cost += float(items[i].sellingStatus.currentPrice.value)
			urls.append(items[i].viewItemURL)
		avg = float(cost)/len(items)	
		print len(items)
		signed_variances = []
		for i in range(len(items)):
			signed_variances.append(float(items[i].sellingStatus.currentPrice.value)-avg)
		#signed_variances.sort()
		second_avg = sum(signed_variances)/len(items)
		signed_second_variances = []
		for i in range(len(items)):
			signed_second_variances.append(((signed_variances[i]-second_avg)/avg))
			if (signed_second_variances[-1]>7.5):
				flagged.append(items[i])
		signed_second_variances.sort()
		print len(flagged)
		#print signed_second_variances
		return flagged


	except ConnectionError as e:
	    print e
	    print e.response.dict()
Exemplo n.º 9
0
def find_it(search):
    api = Connection(config_file='ebay.yaml', debug=DEBUG, siteid="EBAY-US")
    response = api.execute('findItemsByKeywords', search)
    if response.reply.paginationOutput.totalEntries != "0":
        for item in response.reply.searchResult.item:
            print("Title: %s, Price: %s" %
                  (item.title, item.sellingStatus.currentPrice.value))
def get_items(appid, search_keyword, categoryId):
    results = []
    try:
        api = Connection(appid=appid, config_file=None)
        response = api.execute('findItemsAdvanced', {
            'keywords': search_keyword
        }).json()

        item_dict = json.loads(response)
        items = item_dict['searchResult']['item']

        for item in items:
            c_id = item['primaryCategory']['categoryId']
            if c_id != categoryId:
                continue
            autoPay = bool_to_bit(item['autoPay'])
            currentPrice = float(
                item['sellingStatus']['currentPrice']['value'])
            condition = float(item['condition']['conditionId'])
            results.append({
                'input': (autoPay, condition),
                'price': currentPrice
            })

    except ConnectionError as e:
        print(e)
        print(e.response.dict())

    return results
Exemplo n.º 11
0
def search_ebay():
    searchword = request.args.get('q', '')
    for i in colours:
        searchword = searchword.replace(i, '')
    try:
        api = Connection(appid=EBAY_APPID, config_file=None)
        response = api.execute('findItemsAdvanced', {'keywords': searchword})
        #		print int(response.dict()['searchResult']['_count']) == 0
        if int(response.dict()['searchResult']['_count']) == 0:
            return jsonify({"error": "No results found"})
        item = response.reply.searchResult.item[0]
        #		print dir(item)
        pro = "\n\n\n---------------------------------\n"
        pro += "Ebay item name:" + item.title + "\n"
        pro += "Price: " + item.sellingStatus.currentPrice.value + item.sellingStatus.currentPrice._currencyId
        pro += "\n---------------------------------\n"
        write_to_file(pro)
        print pro
        return jsonify({
            "name":
            item.title,
            "price":
            item.sellingStatus.currentPrice.value + ' ' +
            item.sellingStatus.currentPrice._currencyId
        })
    except ConnectionError as e:
        print e
        return jsonify(e.response.dict())
Exemplo n.º 12
0
def startup():
    """
    A function that setups everything up for the server to run

    :return:
    """
    global pandas_obj
    pd.set_option('display.max_rows', 500)
    pd.set_option('display.max_columns', 500)
    pd.set_option(
        'display.width',
        1000)  # Setup the printing of panadas to show the entire output
    pandas_obj = pd.read_csv(
        'db.csv')  # Load the database of ebay items from the file
    db_clean()  # Remove out-of-date entries of ebay items
    cfg_load()  # Load the config from the config file

    api = Connection(config_file='ebay.yaml',
                     siteid="EBAY-US")  # Setup the ebay api for requests
    #if settings[DATE_FILLED].date() < datetime.datetime.now().date():
    #    settings[DATE_FILLED] = datetime.datetime.now()  # This entire section of code isnt
    #    mandetory, but it could be used to fill the db with a small number of big requests instead
    #    of a large number of small requests
    #    db_fill(api)

    return api
Exemplo n.º 13
0
def runQuery(page):
    try:
        api = Connection(appid=ebayAppID, config_file=None)
        response = api.execute(
            'findItemsAdvanced', {
                'keywords':
                'pokemon online code',
                'itemFilter': [{
                    'name': 'ListingType',
                    'value': ['FixedPrice', 'AuctionWithBIN']
                }, {
                    'name': 'FreeShippingOnly',
                    'value': 'true'
                }, {
                    'name': 'MinPrice',
                    'value': '5',
                    'paramName': 'Currency',
                    'paramValue': 'USD'
                }, {
                    'name': 'MaxPrice',
                    'value': '50',
                    'paramName': 'Currency',
                    'paramValue': 'USD'
                }],
                'paginationInput': {
                    'entriesPerPage': 50,
                    'pageNumber': page
                },
                'sortOrder':
                'StartTimeNewest'
            })
    except ConnectionError as e:
        print(e)
        print(e.response.dict())
    return response.dict()
Exemplo n.º 14
0
 def fetch_product(self, identifier):
     self.api = Connection(appid=self.appID, config_file=None)
     args = {
         'keywords': identifier
     }
     response = self.api.execute('findItemsAdvanced', args)
     return response if response.reply.ack == "Success" else None
Exemplo n.º 15
0
 def __init__(self, api_key, keyword):
     self.api_key, self.keyword = api_key, keyword
     # defin which site we wish to connect to and feed in our api-key
     self.api = Connection(siteid='EBAY-US',
                           appid=self.api_key,
                           config_file=None)
     # create a live db cursor
     self.cursor = database_connection()
     # establish lists for appending data to
     self.active_product_ids = []
     self.active_product_nick = []
     self.active_product_titles = []
     self.active_product_prices = []
     self.active_product_cat_names = []
     self.active_product_cat_ids = []
     self.active_product_img_thumb = []
     self.active_product_img_url = []
     self.active_product_lst_type = []
     self.active_product_con = []
     self.active_product_loc = []
     self.active_product_start = []
     self.active_product_end = []
     self.active_product_watch_count = []
     self.active_product_depth = []
     self.depthCountStorage = []
     # outline our search body paramaters
     self.search_body_pages = {
         'keywords':
         keyword,
         'itemFilter': [
             # US only sellers -- can also limit by feedback score, business type, top-rated status, charity, etc.
             {
                 'name': 'MinPrice',
                 'value': '1',
                 'paramName': 'Currency',
                 'paramValue': 'USD'
             },
             {
                 'name': 'MaxPrice',
                 'value': '99999999',
                 'paramName': 'Currency',
                 'paramValue': 'USD'
             },
             # pre-filter to only actionable items (non-bids, etc.)
             {
                 'name': 'ListingType',
                 'value':
                 ['FixedPrice', 'StoreInventory', 'AuctionWithBIN']
             },
         ],
         'paginationInput': {
             'entriesPerPage': '100',
             # always 1, as we want to pull the maximum number of pages given a maximum of 100 results per page
             'pageNumber': '1'
         },
         # can filter this to multiple different options as well (Best Offer, Most Watched, etc.)
         'sortOrder':
         'PricePlusShippingLowest'
     }
Exemplo n.º 16
0
    def handle(self, *args, **options):
        for game in Game.objects.all():
            try:
              api = Connection(appid=settings.EBAY_APP_ID, config_file=None)
              response = api.execute('findCompletedItems', {'keywords': ' '.join(game.slug.split('-')), 'categoryId': '139973'})
              if response.reply.ack == 'Success' and 'item' in response.dict()['searchResult'].keys():
                  for item in response.dict()['searchResult']['item']:
                      if 'productId' in item.keys():
                          if game.epid == item['productId']['value'] and not GameSale.objects.filter(url=item['viewItemURL']).exists() and item['sellingStatus']['sellingState'] == "EndedWithSales" and item['sellingStatus']['convertedCurrentPrice']["_currencyId"] == "USD" and item['country'] == 'US':
                              GameSale.objects.create(
                                  title=item['title'],
                                  game=game,
                                  country=item['country'],
                                  location=item['location'],
                                  url=item['viewItemURL'],
                                  condition=item['condition']['conditionDisplayName'],
                                  price=item['sellingStatus']['convertedCurrentPrice']['value'],
                                  sold=dateutil.parser.parse(item['listingInfo']['endTime'])
                              )
            except ConnectionError as e:
                print(e)
                print(e.response.dict())
                print(game.name)
        for console in Console.objects.all():
            try:
              api = Connection(appid=settings.EBAY_APP_ID, config_file=None)
              response = api.execute('findCompletedItems', {'keywords': ' '.join(console.slug.split('-')), 'categoryId': '139971'})
              if response.reply.ack == 'Success' and 'item' in response.dict()['searchResult'].keys():
                  for item in response.dict()['searchResult']['item']:
                      if 'productId' in item.keys():
                          if console.epid == item['productId']['value'] and not ConsoleSale.objects.filter(url=item['viewItemURL']).exists() and item['sellingStatus']['sellingState'] == "EndedWithSales" and item['sellingStatus']['convertedCurrentPrice']["_currencyId"] == "USD" and item['country'] == 'US':
                              ConsoleSale.objects.create(
                                  title=item['title'],
                                  console=console,
                                  country=item['country'],
                                  location=item['location'],
                                  url=item['viewItemURL'],
                                  condition=item['condition']['conditionDisplayName'],
                                  price=item['sellingStatus']['convertedCurrentPrice']['value'],
                                  sold=dateutil.parser.parse(item['listingInfo']['endTime'])
                              )

            except ConnectionError as e:
                print(e)
                print(e.response.dict())
                print(console.platform.name)
Exemplo n.º 17
0
def commence_search(query):

    try:
        search_term = query
        api = Connection(appid=APP_ID, config_file=None)
        response = api.execute('findItemsByKeywords',
                               {'keywords': search_term})

        assert (response.reply.ack == 'Success')
        assert (type(response.reply.timestamp) == datetime.datetime)
        assert (type(response.reply.searchResult.item) == list)
        item = response.reply.searchResult.item

        search_results = response.dict()

        item = response.reply.searchResult.item[0]
        assert (type(item.listingInfo.endTime) == datetime.datetime)
        assert (type(response.dict()) == dict)
        #print (len(k['searchResult']['item']))

        #print (search_results['searchResult']['item'][0]['itemId'])
        #print (search_results['searchResult']['item'][1]['itemId'])

        item_list = [0] * len(search_results['searchResult']['item'])

        index = 0
        for listing in search_results['searchResult']['item']:

            listing = {
                'id':
                listing['itemId'],
                'title':
                listing['title'],
                'currency':
                listing['sellingStatus']['convertedCurrentPrice']
                ['_currencyId'],
                'price':
                listing['sellingStatus']['convertedCurrentPrice']['value'],
                'start':
                listing['listingInfo']['startTime'],
                'end':
                listing['listingInfo']['endTime'],
                'offerEnabled':
                listing['listingInfo']['bestOfferEnabled'],
                'buyItNowAvailable':
                listing['listingInfo']['buyItNowAvailable'],
                'state':
                listing['sellingStatus']['sellingState']
            }
            item_list[index] = listing
            index += 1
        return item_list

    except ConnectionError as e:

        print(e)
        print(e.response.dict())
Exemplo n.º 18
0
def find_cards():
    """
    List a large number of professionally-graded cards from Ebay.

    Parameters:
    -------
    None

    Returns:
    --------
    None

    Populates the data/page_jsons directory with 100 pages (10,000 total cards)
    for each of the 10 PSA grades. Each page is represented as a pickled JSON object,
    example psa_grade_1_page_1.pkl.

    These pages should then be used to acquire the images associated with each card, as well
    as to provide a unique identifier for each image and a label. 

    Labels are acquired by searching for key terms, e.g. "PSA 9" returns cards graded 9/10 by experts
    """

    # Connect to Ebay API. TODO: add your own API keys.
    client_id = "" # TODO add your own API key.
    dev_id = "" # TODO add your own API key.
    client_secret = "" # TODO add your own API key
    api = Connection(appid=client_id, config_file=None)

    # Downlaod Pages of Ebay API data for each grade.
    grades = range(1, 11) # By default, get data for grades 1, 2, .... 10. 
    for grade in grades:
        for page_num in range(1, 100):

            # get data.
            # note: by default we search for baseball cards only, but this can be expanded, 
            # try e.g. "basketball cards", etc.
            # note that some items do not have large enough images available ("PictureURLLarge") and are ignored.
            params = {
             "categoryName": "Baseball Cards",
             "keywords" : "psa {}".format(grade),
             "paginationInput" : 
                    {
                        "entriesPerPage" : 100, # max 100.
                        "pageNumber" : page_num 
                    },
             "outputSelector" : "PictureURLLarge" # important: if not selected, returned images are too small. 
             }
            response = api.execute("findItemsAdvanced", params)
            j = response.json()

            # save
            of_p = "psa_grade_{}_page_{}.pkl".format(grade, page_num)
            of_p = os.path.join("page_jsons", of_p)
            print(of_p)
            with open(of_p, "wb") as of:
                pickle.dump(j, of)
Exemplo n.º 19
0
def api_all():
    error = False

    response = {'result': 'null'}
    try:
        if 'search' in request.args:
            search = request.args['search']
        else:
            response['error_2'] = "Error: No search field provided. Please search for products."
        link = "https://api.bestbuy.com/v1/products(search={})?format=json&show=name,salePrice,addToCartUrl,largeImage&apiKey=N0ReEPP28MPw3Gd2xSIAQ5dM".format(search)
        data = json.loads(urllib.request.urlopen(link).read().decode()) #Retrieve data from bestbuyAPI
        products = data['products']
        for item in products: #Rename url and include retailer name to the items
            item['url']  = item.pop('addToCartUrl')
            item['retailer'] = 'BestBuy'
        
        #eBay Code 
        api = Connection(config_file='ebay.yaml') #Connect to the API using authentication file
        res = api.execute('findItemsAdvanced', {'keywords': search}) #Retrieve data using eBay developer API

        items = res.reply.searchResult.item[:10] #Only use the first 10 results
        ebay_products = []
        
        for item in items:
            ebay_product = {}
            name = item.get('title') #Retrieve name, price, image, link to purchase product

            sellingStatus = item.get('sellingStatus')
            currentPrice = sellingStatus.get('currentPrice')
            salePrice = float(currentPrice.get('value'))
            
            largeImage = item.get('galleryURL')
            url = item.get('viewItemURL')
            #Format dictionary to match the categories that were used for the Best Buy products
            ebay_product['name'] = name 
            ebay_product['retailer'] = 'eBay'
            ebay_product['salePrice'] =salePrice 
            ebay_product['largeImage'] = largeImage 
            ebay_product['url'] = url
            
            ebay_products.append(ebay_product)
            
        products.extend(ebay_products) #Extend the dictionary to include the ebay products
        products = sorted(products, key = lambda i: i['salePrice']) #Sort by price
        response['result'] = products
    except Exception as err:
        response['error'] = str(err)
        error = True
    
    return sendResponse(response, error)
Exemplo n.º 20
0
 def __init__(self, client):
     self.client = client
     self.api = Connection(appid=os.environ.get('EBAY_APPID'),
                           config_file=None)
     self.run = False
     self.posted_ids = {}
     self.start_time = datetime.now().timestamp()
     self.ignore_ts = False
     self.colors = [
         discord.Color.red(),
         discord.Color.blue(),
         discord.Color.gold(),
         discord.Color.green()
     ]
Exemplo n.º 21
0
def deals(keyword):
    try:
        api = Connection(appid=secrets.ebay, config_file=None)
        response = api.execute('findItemsAdvanced', {'keywords': keyword})

        assert (response.reply.ack == 'Success')
        assert (type(response.reply.timestamp) == datetime.datetime)
        assert (type(response.reply.searchResult.item) == list)

        item = response.reply.searchResult.item[0]
        assert (type(item.listingInfo.endTime) == datetime.datetime)
        assert (type(response.dict()) == dict)
        return response.dict()

    except ConnectionError as e:
        print(e)
        print(e.response.dict())
Exemplo n.º 22
0
def get_list_of_items(request, params=None):
    try:
        api = Connection()
        response = api.execute(request, params)

        assert(response.reply.ack == 'Success')
        assert(type(response.reply.timestamp) == datetime.datetime)
        # assert(type(response.reply.searchResult.item) == list)
#todo if empty list
        # item = response.reply.searchResult.item[0]
        # assert(type(item.listingInfo.endTime) == datetime.datetime)
        # assert(type(response.dict()) == dict)
        return response.dict()

    except ConnectionError as e:
        print(e)
        print(e.response.dict())
Exemplo n.º 23
0
def find_it(search, existing_ids):
    api = Connection(config_file='ebay.yaml', debug=DEBUG, siteid="EBAY-US")
    response = api.execute('findCompletedItems', search)
    result_list = []
    if response.reply.paginationOutput.totalEntries != "0":
        for item in response.reply.searchResult.item:
            if str(item.itemId) not in existing_ids:
                result_list.append({
                    "item_id":
                    item.itemId,
                    "title":
                    item.title,
                    "end_date":
                    item.listingInfo.endTime,
                    "price":
                    item.sellingStatus.currentPrice.value
                })
    return result_list
Exemplo n.º 24
0
def search(opts, keywords, category_id, n_listings=100):
    print("KEYWORDS", keywords)
    try:
        api = Connection(config_file=opts['config_fpath'], appid=opts['appid'])
        response = api.execute('findItemsAdvanced', {'keywords': keywords})

        assert (response.reply.ack == 'Success')
        assert (type(response.reply.timestamp) == datetime.datetime)
        print(response.dict())
        assert (type(response.reply.searchResult.item) == list)

        items = response.reply.searchResult.item[:n_listings]
        assert (type(response.dict()) == dict)
        return response.dict()

    except ConnectionError as e:
        print(e)
        print(e.response.dict())
Exemplo n.º 25
0
def get_history(request):
    if request.method == 'POST':
        data = request.POST.get('data')
        data = json.loads(data)
        if 'search' in data:
            keywords = data['search']
            try:
                api = Connection(appid='JeffreyC-Streetwe-PRD-f2f871c7c-922e659d', config_file=None)
                response = api.execute('findCompletedItems', {'keywords': keywords})
                return HttpResponse(response.json())

            except ConnectionError as e:
                return HttpResponse("Connection error.")

        else:
            return HttpResponse("No search.")
    else:
        return HttpResponse("Must be a POST request.")
Exemplo n.º 26
0
def EbayAPI(search_content, items_list):
    try:
        api = Connection(appid='MaozhiTa-MoDeal-PRD-0c22b8256-f6e60466',
                         config_file=None)
        response = api.execute('findItemsAdvanced',
                               {'keywords': search_content})

        assert (response.reply.ack == 'Success')
        assert (type(response.reply.timestamp) == datetime.datetime)
        assert (type(response.reply.searchResult.item) == list)

        append_num = 0
        i = 0
        while i < len(response.reply.searchResult.item) and append_num < 10:
            if response.reply.searchResult.item[
                    i].galleryURL != 'http://thumbs1.ebaystatic.com/pict/04040_0.jpg':  # and response.reply.searchResult.item[i].condition.conditionDisplayName == 'New':
                title = response.reply.searchResult.item[i].title
                price = '$' + response.reply.searchResult.item[
                    i].sellingStatus.currentPrice.value
                # price=response.reply.searchResult.item[i].sellingStatus.currentPrice.value
                # price+=' '+response.reply.searchResult.item[i].sellingStatus.currentPrice._currencyId
                url = response.reply.searchResult.item[i].viewItemURL
                picture = response.reply.searchResult.item[i].galleryURL
                temp = {
                    'source': 'Ebay',
                    'picture': picture,
                    'name': title,
                    'price': price,
                    'url': url
                }
                items_list.append(temp)
                append_num += 1
            i += 1
            #print(response.reply.searchResult.item[i].condition)
            #print(response.reply.searchResult.item[i].galleryURL)

        item = response.reply.searchResult.item[0]
        assert (type(item.listingInfo.endTime) == datetime.datetime)
        assert (type(response.dict()) == dict)

    except ConnectionError as e:
        print(e)
        print(e.response.dict())
Exemplo n.º 27
0
def ebay_search(keywords):
    """
    Search Ebay for given keywords.
    returns: list of items
    """

    try:
        api = Connection(appid=settings.EBAY_API_KEY, config_file=None)
        response = api.execute('findItemsAdvanced', {'keywords': keywords})

        assert response.reply.ack == 'Success'
        assert isinstance(response.reply.timestamp, datetime.datetime)
        assert isinstance(response.reply.searchResult.item, list)
        assert isinstance(response.dict(), dict)
        items = response.reply.searchResult.item
        return items

    except ConnectionError:
        return None
Exemplo n.º 28
0
def joo_ebay():
    items_list2 = []
    C = 0
    api = Connection(appid='Shaked-B-976d-45bc-a23a-71ab251884fb',
                     config_file=None,
                     debug=True)
    #response details:
    response = api.execute('getTopSellingProducts')

    assert (response.reply.ack == 'Success')
    assert (type(response.reply.timestamp) == datetime.datetime)
    assert (type(response.reply.searchResult.item) == list)

    item = response.reply.searchResult.item[0]
    assert (type(item.listingInfo.endTime) == datetime.datetime)
    assert (type(response.dict()) == dict)

    for ITEM in response.reply.searchResult.item:
        print ITEM
    def run(self, jsondata):
        print("Running ebay crawler...")
        request = self.ObtainRequest(jsondata)

        try:
            api = Connection(config_file='ebay.yaml', siteid="EBAY-US")
            # ebay.yaml contains the ebay credentials to allow the crawler to work

            response = api.execute('findItemsAdvanced', request)

            assert (response.reply.ack == 'Success')

            data = self.cleanData(response.json(), jsondata["Make"],
                                  jsondata["Model"])

            return data

        except ConnectionError as e:
            print(e)
            print(e.response.dict())
Exemplo n.º 30
0
def find_product(upc):
    try:
        api = Connection(domain='svcs.ebay.com',
                         appid="PEGGYXUE-MySecond-PRD-551ca6568-4365441b",
                         config_file=None)
        response = api.execute('findItemsByProduct',
                               '<productId type="UPC">%s</productId>' % upc)
        data = response.dict()
        #print(data)

        if response.reply.ack == 'Failure':
            sys.exit('Error! %s' % response.reply.errorMessage.error.message)

        itemlist = data['searchResult']['item']
        record = generate_record(itemlist)
        #print(record)

    except ConnectionError as e:
        print(e)
        print(e.response.dict())