Initial commit
This commit is contained in:
38
scraper_utilities/angolajsontest.py
Normal file
38
scraper_utilities/angolajsontest.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user