コード例 #1
0
ファイル: lookup.py プロジェクト: peterbe/generousfriends
    def handle(self, *args, **options):
        api = amazonproduct.API(locale='us')
        for arg in args:
            information = scrape.scrape(arg)
            #pprint(information)
            #scrape.scrape(arg)
            asins = []
            for item in information['items']:
                #if 'B002LARRDK' not in item['url']:
                #    continue
                print item['text']
                asin = lookup.url_to_asin(item['url'])
                #print "ASIN", repr(asin)
                asins.append(asin)

            looker = lookup.ItemLookup(asins)

            """
コード例 #2
0
 def _convert(self, wishlist):
     print "IDENTIFIER", wishlist.identifier, wishlist.email
     asins = {}
     for item in models.Item.objects.filter(wishlist=wishlist, amazon_api_converted=False):
         print "\t", repr(item.title[:90])
         asin = lookup.url_to_asin(item.url)
         asins[asin] = item
     try:
         self._convert_asins(asins)
     except (lookup.ItemNotAccessible, lookup.NoImage):
         # we have to do one at a time :(
         for asin, item in asins.items():
             if item.amazon_api_converted:
                 continue
             try:
                 self._convert_asins({asin: item})
             except lookup.ItemNotAccessible:
                 print "\t\tBAD ASIN", asin, repr(item.title)
                 pass
             except lookup.NoImage:
                 print "\t\tBAD ASIN NO IMAGE", asin, repr(item.title)
                 pass