Created
          November 21, 2019 18:58 
        
      - 
      
- 
        Save nickcjohnston/f031b82a250840d4687d0e9b972468c4 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import sys | |
| import datetime | |
| from ebaysdk.finding import Connection | |
| #usage: python3 ebay-find-short-auctions.py ebay.yaml KEYWORDS | |
| config = sys.argv[1] | |
| keywords = " ".join(sys.argv[2:]) | |
| api = Connection(config_file=config, siteid="EBAY-US") | |
| sixty_from_now = (datetime.datetime.utcnow() + datetime.timedelta(minutes=60)).isoformat() | |
| request = { | |
| 'keywords':keywords, | |
| 'itemFilter': [ | |
| {'name':'Condition', 'value':'New'}, | |
| {'name':'EndTimeTo', 'value': sixty_from_now}, | |
| ], | |
| 'pageinationInput': { | |
| 'entriesPerPage': 10, | |
| 'pageNumber':1, | |
| }, | |
| 'sortOrder':'PricePlusShippingLowest', | |
| 'outputSelector':'SellerInfo', | |
| } | |
| response = api.execute('findItemsByKeywords', request) | |
| for item in response.reply.searchResult.item: | |
| auction_title = item.title.replace(",", " ") | |
| price = item.sellingStatus.currentPrice.value | |
| currency = item.sellingStatus.currentPrice._currencyId | |
| auction_duration_days = (item.listingInfo.endTime - item.listingInfo.startTime).days | |
| auction_duration = (item.listingInfo.endTime - item.listingInfo.startTime) | |
| sellerName = item.sellerInfo.sellerUserName | |
| if auction_duration_days <= 7: | |
| print(f"Title: {auction_title}, Price: {price} ({currency}), Listing Duration: {auction_duration}, Seller Name: {sellerName}") | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment