Skip to content

Instantly share code, notes, and snippets.

@nickcjohnston
Created November 21, 2019 18:58
Show Gist options
  • Save nickcjohnston/f031b82a250840d4687d0e9b972468c4 to your computer and use it in GitHub Desktop.
Save nickcjohnston/f031b82a250840d4687d0e9b972468c4 to your computer and use it in GitHub Desktop.
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