ebay-ml-lister/ebay_api_test.py
2020-08-23 06:08:15 -07:00

42 lines
1.7 KiB
Python

import requests
import json
from bs4 import BeautifulSoup as b
# with open('cat_list') as jf:
# cat_list = json.load(jf)
departments = ["3034","93427"]
# keywords = input('keyword search: ')
for categoryID in departments:
params = {
"OPERATION-NAME":"findItemsByCategory",
"SECURITY-APPNAME":"scottbea-xlister-PRD-6796e0ff6-14862949",
"SERVICE-VERSION":"1.13.0",
"RESPONSE-DATA-FORMAT":"JSON",
"categoryId":categoryID ,
"paginationInput.entriesPerPage":"100",
"outputSelector":"AspectHistogram"
}
response = requests.get("https://svcs.ebay.com/services/search/FindingService/v1", params=params) #
data = response.json()
pretty_data = json.dumps(data, indent=2)
# header_dict = dict(response.headers)
# pretty_header = json.dumps(header_dict, indent=2)
# results = data['findItemsByCategoryResponse'][0]['searchResult'][0]['item']
# Before moving onto to the Trading api make sure you check to see if the Finding api will
# output the labels you need. Look into "outputselector" and "aspectfilter" on the
# Finding api --> "finditembykeyword" or other specific calls
# I think you'll have to paginate the results to output an aspecthistogram cause you might be getting too many results per call.
# Additional problem you will run into when getting labeled data is shoe types and features not in features, accents, styles, categories or subcategories.
# Also, if you can filter by category ids after conducting a very broad search maybe that will be a good way to return the aspect histogram. But you may have to just to a search for each ctegory and return the item specifics, create a giant pandas df and find make a list from the unique specifics/ labels