Created
February 6, 2017 21:36
-
-
Save kgerst/01ad0c8760a7a3ea6e3c44849cf0336b to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
import os | |
import requests | |
from datetime import datetime | |
def getPage(cursorMark): | |
response = requests.get( | |
'https://api.bestbuy.com/v1/products', | |
params = { | |
'pageSize': '100', | |
'cursorMark': cursorMark, | |
'format': 'json', | |
'apiKey': os.environ['API_KEY'], | |
}) | |
return response.json() | |
if __name__ == "__main__": | |
page = getPage('*') | |
while len(page['products']) > 0: | |
print('%s\tproducts: %s\tfirst product: %s' % (datetime.now(), len(page['products']), page['products'][0]['sku'])) | |
page = getPage(page['nextCursorMark']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment