From 6fb262d7f6feb6105ec73a9dcd97f27783ce8b17 Mon Sep 17 00:00:00 2001 From: Geo Halkiadakis Date: Tue, 21 Mar 2023 13:01:27 +0200 Subject: new node-js implementation; input from json --- python/products-dict-v5.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'python/products-dict-v5.py') diff --git a/python/products-dict-v5.py b/python/products-dict-v5.py index 8d32586..a0a8965 100644 --- a/python/products-dict-v5.py +++ b/python/products-dict-v5.py @@ -9,6 +9,7 @@ import mysql.connector as mysql # mysql connector import re # regex import json # json +import ijson # json import os.path # ... import sys from urllib.request import urlopen @@ -333,7 +334,7 @@ for it in synonymOriginals : ## get data from endpoint (url) -url = "http://localhost/api/v1/productsSearch" +url = "https://emarket-laravel-dlqjpfxz5q-oa.a.run.app/api/v1/productsSearch" json_url = urlopen(url) received = json.loads(json_url.read()) @@ -341,7 +342,7 @@ received = json.loads(json_url.read()) # print(data) # sys.exit() - +print ('products loaded') # --- Lists to fill keywords_ = [] # all data @@ -389,8 +390,7 @@ for rec in received['data'] : description = rec['txt'] pid = ['id'] - fq = 1 - + fq = 1 # setup product # --- @@ -448,11 +448,11 @@ for it in keywords_ : ## OUTPUT final data to a json-format file # ////////////////////////////////////////////////////////////////////////////// -with open("./keywords-v5.json", "w", encoding="utf-8") as outfile : +with open("./results/keywords-v5.json", "w", encoding="utf-8") as outfile : data = json.dump(keywords_, outfile, sort_keys=False, indent=3, ensure_ascii=False) -with open("./minilist-v5.json", "w", encoding="utf-8") as outfile : +with open("./results/minilist-v5.json", "w", encoding="utf-8") as outfile : data = json.dump(minilist_, outfile, sort_keys=False, indent=3, ensure_ascii=False) -with open("./products-v5.json", "w", encoding="utf-8") as outfile : +with open("./results/products-v5.json", "w", encoding="utf-8") as outfile : data = json.dump(products_, outfile, sort_keys=False, indent=3, ensure_ascii=False) \ No newline at end of file -- cgit v1.2.3