Exemplo n.º 1
0
    def GET(self):
        response = json.loads(findItemsAdvanced(
            keywords='lego lbs -mega -manual -instruction',
            sortOrder = 'EndTimeSoonest',
        ))
        
        page = response['findItemsAdvancedResponse'][0]
        results = page['searchResult'][0]
        items = results['item']

        lbs_match = re.compile('.*?([0-9\.\- ]+)[ +]*(lb|pound)',re.I)
        
        items_list = []

        for item in items:
            item['price'] = item['sellingStatus'][0]['currentPrice'][0]['__value__']
            item['title'] = item['title'][0].lower()
            item['title'] = item['title'].replace('lego','LEGO')
            
            for frac in [('1/4','.25'),('1/2','.5'),('3/4','.75')]:
                item['title'] = item['title'].replace(' ' + frac[0],frac[1])
                item['title'] = item['title'].replace(frac[0],frac[1])
            
            # End Time
            item['end_time'] = item['listingInfo'][0]['endTime'][0]
            item['end_time'] = item['end_time'].replace('T',' ')
            item['end_time'] = item['end_time'].replace('.000Z','')
            
            # Weight
            try:
                item['weight'] = lbs_match.match(item['title'].replace(' to ','-')).group(1)
                item['weight'] = item['weight'].split('-')[0]
            except:
                item['weight'] = None
            
            # Shipping
            try:
                item['shipping_type'] = item['shippingInfo'][0]['shippingType'][0]
                
                if item['shipping_type'] == 'Calculated':
                    # Rough estimate, could use GetShippingCosts for higher accuracy
                    item['shipping_price'] = float(item['weight']) * 3.49
                else:
                    item['shipping_price'] = item['shippingInfo'][0]['shippingServiceCost'][0]['__value__']
            except:
                item['shipping_price'] = None
            
            # Price
            try:
                item['total_price'] = float(item['shipping_price']) + float(item['price'])
                item['price_per_pound'] = item['total_price'] / float(item['weight'])
                item['price_per_pound'] = "%.2f" % item['price_per_pound']
            except:
                item['total_price'] = None
                item['price_per_pound'] = None
            
            if item['price_per_pound'] and float(item['price_per_pound']) < 10.0:
                items_list.append(item)
            
        return render.list(items_list)
Exemplo n.º 2
0
    def test_findItemsAdvanced(self):
        result = findItemsAdvanced(
                      keywords=keywords, \
                      categoryId=categoryId, \
                      affiliate=affiliate, \
                      buyerPostalCode=buyerPostalCode, \
                      paginationInput= paginationInput, \
                      sortOrder=sortOrder, \
                      aspectFilter=aspectFilter, \
                      domainFilter=domainFilter, \
                      itemFilter=itemFilter, \
                      outputSelector=outputSelector, \
                      encoding=encoding)
#        print result
        root = etree.fromstring(result)
        ack = root.find("{http://www.ebay.com/marketplace/search/v1/services}ack").text
        self.assertEqual(ack, "Success")
        #Number of Items between 0 and 10, because of paginationInput
        res_items = root.find("{http://www.ebay.com/marketplace/search/v1/services}searchResult")
        self.assertTrue(0 <= len(res_items) <= 10)
Exemplo n.º 3
0
    def test_findItemsAdvanced(self):
        result = findItemsAdvanced(
                      keywords=keywords, \
                      categoryId=tegoryId, \
                      affiliate=affiate, \
                      buyerPostalCodeuyerPostalCode, \
                      paginationInput= ginationInput, \
                      sortOrder=sortOrder\
                      aspectFilter=aspectFier, \
                      domainFilter=domainFilt, \
                      itemFilter=itemFilter, \
                    outputSelector=outputSelect, \
                      encoding=encoding)
#        pnt result
        root = etree.fromstring(result)
        ack = root.find("{http://www.ebay.com/marketplace/search/v1/services}ack").text
        self.assertEqual(ack, "Success")
        #Number of Items between 0 and 10, because of paginationInput
        res_items = root.find("{http://www.ebay.com/marketplace/search/v1/services}searchResult")
        self.assertTrue(0 <= len(res_items) <= 10)
Exemplo n.º 4
0
		if(numberOfItems > 0):
			logging.info("Multiple items:" + count )
			for item in items:
				processItem(item)
		else:
			#single item
			logging.info("Single item:" + count )
			processItem(items)	
	else:
		print "No items for search " + ebaySearchTerms
		logging.info("No items:" + count )	

if  __name__ =='__main__':

	outputSelector =["PictureURLSuperSize"]
	advancedSearchResult = findItemsAdvanced(keywords="dimensions sprewell", outputSelector=outputSelector)


	# findItemsAdvancedResponse = json.loads(advancedSearchResult)['findItemsAdvancedResponse']

	# for response in findItemsAdvancedResponse:
	# 	for searchResult in response['searchResult']:
	# 		processSearchResult(searchResult)

	completedItemsSearchResult = findCompletedItems(keywords="1997 star rubies", outputSelector=outputSelector)

	completedItems = json.loads(completedItemsSearchResult)['findCompletedItemsResponse']
	pprint.pprint(completedItems)

	for completeItem in completedItems:
	 	for searchResult in completeItem['searchResult']:
Exemplo n.º 5
0
from ebay.finding import getSearchKeywordsRecommendation, findItemsByKeywords, findItemsByCategory, findItemsAdvanced, findItemsByProduct, findItemsIneBayStores, getHistograms

print getSearchKeywordsRecommendation(encoding="XML", keywords="acordian")
print findItemsByKeywords(keywords="ipod")
print findItemsByCategory(categoryId="123")
print findItemsAdvanced()
print findItemsByProduct(productId="123")
print findItemsIneBayStores()
print getHistograms(categoryId="12")