39 lines
899 B
Python
39 lines
899 B
Python
"""
|
|
Used for parsing saved json response from angola-based websites
|
|
"""
|
|
|
|
import json
|
|
|
|
with open('testing.json', 'r') as f:
|
|
st = f.read()
|
|
|
|
decoded = json.loads(st)
|
|
|
|
products = decoded['hits']
|
|
|
|
for product in products:
|
|
bad_conditions = [
|
|
product['product_type'].lower() in ["gift card", "music"],
|
|
not product['product_published'],
|
|
'product' not in product
|
|
]
|
|
if any(bad_conditions):
|
|
continue
|
|
|
|
if 'product' not in product:
|
|
print(json.dumps(product))
|
|
break
|
|
|
|
item_info = {
|
|
"ShopSourceID": 1,
|
|
"Url": 'https://www.jbhifi.com.au/products/' + product['handle'],
|
|
"BaseUrl": "jbhifi.com.au",
|
|
"SKU": product['sku'],
|
|
"MPN": product['product']['supplierProductDetails'][0]['supplierStockCode'],
|
|
"Model": product['product']['model'],
|
|
"Title": product['title'],
|
|
"PriceIncTax": product['price'],
|
|
"IsInStock": product['availability']['canBuyOnline'],
|
|
"QuantityAvailable": None
|
|
}
|