timotheus / ebaysdk-python

eBay API SDK for Python
https://developer.ebay.com/tools/sdks
Other
796 stars 321 forks source link

findItemsAdvanced doesn't search .co.uk site #265

Open aadon94 opened 5 years ago

aadon94 commented 5 years ago

I'm doing an advanced search like so with Global-ID set to 'EBAY-GB' but the results are clearly still searching the ebay.com site.

        api_request = {
            'GLOBAL-ID': 'EBAY-GB',
            'keywords': keywords,
            'itemFilter': [
                {'name': 'Condition',
                 'value': product.condition},
                {'name': 'LocatedIn',
                 'value': 'GB'}
            ]
        }

        # Search for new listings
        response = api.execute('findItemsAdvanced', api_request)

The results are different to if I did an advanced search on the ebay.co.uk site. The results from the api call are identical to if I did an advanced search on ebay.com. And these results are very different to the ebay.co.uk ones. Is there anyway to fix this?

dalepotter commented 5 years ago

I just had this problem too!

It seems that the header for the desired eBay site is build as a request header. Therefore you can use the siteid keyword when instantiating the connection (or in your config file if you prefer).

api = Connection(appid='YOUR_APPID_HERE', siteid='EBAY-GB', config_file=None)

then do your thing with...

api_request = {
    'keywords': 'python',
    'itemFilter': [
        {'name': 'Condition',
                 'value': 'Used'},
        {'name': 'LocatedIn',
                 'value': 'GB'}
    ]
}

# Search for new listings
response = api.execute('findItemsAdvanced', api_request)

You can also confirm the listing using the corresonding search URL:

> response.reply.itemSearchURL
'http://www.ebay.co.uk/sch/i.html?LH_ItemCondition=2&LH_LocatedIn=1&_nkw=python&_ddo=1&_fls=1&_ipg=100&_pgn=1&_salic=3'