Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch Requests #1

Closed
ghost opened this issue Jun 9, 2012 · 5 comments
Closed

Batch Requests #1

ghost opened this issue Jun 9, 2012 · 5 comments

Comments

@ghost
Copy link

ghost commented Jun 9, 2012

Is there a way to do a search for multiple items in a single request (batch requests)?. This is very important because of amazon's one second rule. It does look like some one has implemented it elsewhere as I found this forum post.

@yoavaviram
Copy link
Owner

Hi,

I added support for some lookup batch requests:

 >>> from amazon.api import AmazonAPI
 >>> amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY,

AMAZON_ASSOC_TAG)
>>> products =
amazon.lookup(ItemId="B0051QVESA,B005DOK8NW,B005890G8Y,B0051VVOB2,B005890G8O")
>>> len(products)
5
>>> products[0].asin
'B0051QVESA'

Is this what you where looking for?

Yoav.

On Sat, Jun 9, 2012 at 8:12 AM, objektek <
reply@reply.github.com

wrote:

Is there a way to do a search for multiple items in a single request
(batch requests).
This is very important because of amazon's one second rule. It does look
like some one has implemented it elsewhere as I found this forum post.


Reply to this email directly or view it on GitHub:
#1

@ghost
Copy link
Author

ghost commented Jun 12, 2012

Yoav, what I meant was searching multiple items (upto maybe 10 at a time), ie. using multiple keywords, like so...
amazon.search(Keywords="keyword1, keyword2, keyword3, keyword4, ...")

@yoavaviram
Copy link
Owner

I don't think that using multiple keywords in such a way is supported. Can
you find any examples of someone using bulk search requests?

On Tue, Jun 12, 2012 at 8:28 PM, objektek <
reply@reply.github.com

wrote:

Yoav, what I meant was searching multiple items (upto maybe 10 at a time),
ie. using multiple keywords, like so...
amazon.search(Keywords="keyword1, keyword2, keyword3, keyword4, ...")


Reply to this email directly or view it on GitHub:

#1 (comment)

@ghost
Copy link
Author

ghost commented Jun 16, 2012

I haven't seen it used elsewhere but with a slight mod bottlenose I could only get it to work with two keywords at a time. I guess the only way to do it is to do a loop with two keywords at a time.

def search_amazon(keywords):

    sk = {}

    for idx, val in enumerate(keywords):
        if idx < 3:
            keyName = "ItemSearch."+str(idx+1)+".Keywords"
            sk[keyName] = val

    import bottlenose
    amazon = bottlenose.Amazon(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)
    products = amazon.ItemSearch(SearchIndex='MP3Downloads', searchKeywords=sk)

    from lxml import objectify, etree

    return objectify.fromstring(products)

In bottlenose def call(self, **kwargs), i did:

        searchKeywords = kwargs['searchKeywords']
        for key in searchKeywords.keys():
            kwargs[key] = searchKeywords[key]

@yoavaviram
Copy link
Owner

If all we get from this change is running
two search queries in parallel, than i don't think it is worth implementing
at this point.

Thanks!

On Wed, Jun 20, 2012 at 5:58 AM, objektek <
reply@reply.github.com

wrote:

I haven't made any other changes. I just the following piece to bottlenose
api.py line79 and that produces an XML response with search results for two
keywords but not more:

                    searchKeywords = kwargs['searchKeywords']
                    for key in searchKeywords.keys():
                            kwargs[key] = searchKeywords[key]

After adding the above code to bottlenose, do a search with a list of two
keywords for the searchKeywords parameter, like so:

 >>> import bottlenose
 >>> amazon = bottlenose.Amazon(AMAZON_ACCESS_KEY_ID,

AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)
>>> response = amazon.ItemSearch(searchKeywords=["Kindle
3G","Pizza"], SearchIndex="All")


Reply to this email directly or view it on GitHub:

#1 (comment)

yoavaviram pushed a commit that referenced this issue Feb 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant