Add category field, update datasheet extracted fields
This commit is contained in:
parent
4a78586c34
commit
f06540f568
@ -82,6 +82,7 @@ def query_search(partnum, source):
|
||||
desc = a["results"][idx]["raw"]["catalogitemlongdesc"]
|
||||
shortdesc = a["results"][idx]["raw"]["catalogitemshortdesc"]
|
||||
app = a["results"][idx]["raw"]["catalogitemapplication"]
|
||||
category = a["results"][idx]["raw"]["catalogitemfilterproductcategory"]
|
||||
|
||||
#a = json.dumps(a["results"][idx], indent=2)
|
||||
#print(a, urlname, img, uri, dsurl)
|
||||
@ -93,6 +94,7 @@ def query_search(partnum, source):
|
||||
out["short_description"] = shortdesc
|
||||
out["description"] = desc
|
||||
out["application"] = app
|
||||
out["category"] = category
|
||||
out["image"] = "https://www.belden.com" + img
|
||||
out["partnum"] = name
|
||||
#print(out)
|
||||
|
@ -387,6 +387,10 @@ def parse(filename, output_dir, partnum, dstype, weburl, extra):
|
||||
output_table["application"] = extra["application"]
|
||||
output_table["fullspecs"]["application"] = extra["application"]
|
||||
output_table["searchspecs"]["application"] = extra["application"]
|
||||
if "category" in extra:
|
||||
output_table["category"] = extra["category"]
|
||||
output_table["fullspecs"]["category"] = extra["category"]
|
||||
output_table["searchspecs"]["category"] = extra["category"]
|
||||
|
||||
output_table["searchspecs"]["id"] = id
|
||||
|
||||
|
19
run.py
19
run.py
@ -169,29 +169,30 @@ def check_server():
|
||||
fs = cabledata["fullspecs"]
|
||||
tmp1 = {"part_number": cable_list[idx], "position": idx, "name": cable_list[idx], "brand": cabledata["brand"] }
|
||||
if "Product Overview" in fs and "Product Category" in fs["Product Overview"]:
|
||||
tmp1["short_description"] = fs["Product Overview"]["Product Category"]
|
||||
tmp1["category"] = fs["Product Overview"]["Product Category"]
|
||||
if "Product Overview" in fs and "Suitable Applications" in fs["Product Overview"]:
|
||||
if len(fs["Product Overview"]["Suitable Applications"]) == 0 or not isinstance(fs["Product Overview"]["Suitable Applications"], str):
|
||||
print(cable_list[idx], fs["Product Overview"]["Suitable Applications"])
|
||||
for key, value in fs["Product Overview"].items():
|
||||
#print(key,value)
|
||||
if len(value) > 5 and isinstance(value, str):
|
||||
tmp1["description"] = value
|
||||
tmp1["application"] = value
|
||||
elif len(key) > 15 and not isinstance(value, str):
|
||||
tmp1["description"] = key
|
||||
tmp1["application"] = key
|
||||
else:
|
||||
tmp1["description"] = fs["Product Overview"]["Suitable Applications"]
|
||||
tmp1["application"] = fs["Product Overview"]["Suitable Applications"]
|
||||
elif "Product Overview" in fs and "Suitable Applications:" in fs["Product Overview"]:
|
||||
if len(fs["Product Overview"]["Suitable Applications:"]) == 0 or not isinstance(fs["Product Overview"]["Suitable Applications:"], str):
|
||||
print(cable_list[idx], fs["Product Overview"]["Suitable Applications:"])
|
||||
for key, value in fs["Product Overview"].items():
|
||||
#print(key,value)
|
||||
if len(value) > 5 and isinstance(value, str):
|
||||
tmp1["description"] = value
|
||||
tmp1["application"] = value
|
||||
elif len(key) > 15 and not isinstance(value, str):
|
||||
tmp1["description"] = key
|
||||
tmp1["application"] = key
|
||||
else:
|
||||
tmp1["description"] = fs["Product Overview"]["Suitable Applications:"]
|
||||
tmp1["application"] = fs["Product Overview"]["Suitable Applications:"]
|
||||
|
||||
if "image" in cabledata:
|
||||
tmp1["image"] = cabledata["image"]
|
||||
if "description" in cabledata:
|
||||
@ -200,7 +201,9 @@ def check_server():
|
||||
tmp1["short_description"] = cabledata["short_description"]
|
||||
if "application" in cabledata:
|
||||
tmp1["application"] = cabledata["application"]
|
||||
|
||||
if "category" in cabledata:
|
||||
tmp1["category"] = cabledata["category"]
|
||||
|
||||
tmp.append(tmp1)
|
||||
out = {"map": tmp}
|
||||
fprint(out)
|
||||
|
Loading…
x
Reference in New Issue
Block a user