This commit is contained in:
scott 2022-01-04 20:53:34 -07:00
parent fc793f4456
commit e879e80910

View File

@ -185,17 +185,17 @@ class ShoppingApi:
response = requests.get(url, headers=headers,timeout=24)
response.raise_for_status()
response = response.json()
response = response['Item']
print(response)
item = response['Item']
except (requests.exceptions.RequestException, KeyError):
print('connection error. IP limit possibly exceeded')
return # returns NoneType. Handle at conky()
print(response)
return # returns NoneType. Handled at conky()
return response
return item
def conky(self):
def conky(self, twenty_ids_list):
'''
Runs get_item_from_findItemsByCategory in multiple threads to get relevant
data for creating training sets
@ -206,15 +206,8 @@ class ShoppingApi:
except (FileNotFoundError, ValueError):
data = []
try:
with open('item_id_results.txt') as f: # TODO fix here
item_id_results = json.load(f)
except (FileNotFoundError, ValueError):
item_id_results = scrape_ids.main()# TODO fix here
with concurrent.futures.ThreadPoolExecutor() as executor:
for future in executor.map(self.get_item_from_findItemsByCategory, item_id_results):
for future in executor.map(self.get_item_from_findItemsByCategory, twenty_ids_list):
if future is not None:
for item in future:
data.append(item) # The end result should be a list of dicts where each dict in the list is a listing