ebay-ml-lister/try.py

38 lines
1007 B
Python
Raw Normal View History

2021-12-31 22:08:48 +00:00
import ebaysdk
import json
import requests
import concurrent.futures
import config as cfg
from ebaysdk.shopping import Connection as Shopping
from ebaysdk.trading import Connection as Trading
sapi = Shopping(config_file = 'ebay.yaml')
tapi = Trading(config_file='ebay.yaml')
def get_cat_specs(cat):
response = tapi.execute('GetCategorySpecifics',
{'CategoryID':cat})
cat_spacs =[name['Name'] for name in response.dict()['Recommendations']['NameRecommendation']]
return cat_spacs
with open('cat_list.txt') as f:
cat_list = json.load(f)
def threadd_cat_spacs():
cat_spacs = []
with concurrent.futures.ThreadPoolExecutor() as executor:
for future in executor.map(get_cat_specs, cat_list):
cat_spacs.extend(future)
cat_spacs = list(set(cat_spacs))
return cat_spacs
if __name__=='__main__':
cat_spacs = threadd_cat_spacs()
with open('cat_spacs.txt', 'w') as f:
json.dump(cat_spacs, f)