2017-02-14 94 views
0

我是新來的eBay API,但我試圖用它來查看完成的拍賣。我找到了Python包ebaysdk,並且安裝並運行了最新版本。但是,如果我運行查詢並取回結果,然後再次立即運行它,相同的參數和所有內容,我會得到完全不同的結果。此外,我第一次運行它時,我確實找回了一些拍賣物品的拍賣地點,但經過多次嘗試,我只收到沒有出售的物品。ebaysdk:findCompletedListing不會返回一致的結果

我的實現遵循作者在GitHub上看到的示例。我唯一的區別是自動迭代頁碼以在第一頁之前獲得額外的結果。

我不確定問題是什麼,但希望有人在這裏。結果之間的細微變化是可以理解的,但我無法理解爲什麼我會多次得到運行完全相同查詢的完全不同的結果。

from ebaysdk.finding import Connection as Finding 
from ebaysdk.exception import ConnectionError 

# define eBay API credentials 
sandbox_id = '123456789' 
prod_id = '123456789' 

# test API in sandbox 
api = Finding(domain='svcs.sandbox.ebay.com', appid=sandbox_id, config_file=None) 
response = api.execute('findCompletedItems', {'categoryId': '6161'}) 
pprint(response.dict()) 

# query the API and store results 
results = [] 
page_num = 1 

while True: 

    try: 
     api = Finding(appid=prod_id, config_file=None) 
     response = api.execute('findCompletedItems', {'categoryId': '6161', 'paginationInput': {'pageNumber': page_num}}) 
     r = response.dict() 

     if r['ack'] == "Success": 
      results.append(r) 

     else: 
      print(r) 
      break 

    except ConnectionError as e: 
     print(e) 
     print(e.r) 
     break 

    page_num += 1 

回答

相關問題