Ben 6 mesi fa
parent
commit
e04b598cbf
6 ha cambiato i file con 3266 aggiunte e 28 eliminazioni
  1. BIN
      .DS_Store
  2. 3133 0
      data2.json
  3. 106 24
      main.py
  4. BIN
      output_卡奇尔.xlsx
  5. 7 0
      parse_params.py
  6. 20 4
      test.py

BIN
.DS_Store


File diff suppressed because it is too large
+ 3133 - 0
data2.json


File diff suppressed because it is too large
+ 106 - 24
main.py


BIN
output_卡奇尔.xlsx


File diff suppressed because it is too large
+ 7 - 0
parse_params.py


+ 20 - 4
test.py

@@ -1,16 +1,32 @@
 import json
 import pandas as pd
 
-with open('data.json', 'r') as f:
+with open('data2.json', 'r') as f:
     data = json.load(f)
 
 try:
-    list = data['stores']['store']['data']['ssrListData']['list']
+    goods = []
+    items = data['items']
+    for item in items:
+        goods_model = item['item_data']['goods_model']
+
+        goods_id = str(goods_model['goods_id'])
+        goods_name = goods_model['goods_name']
+        link_url = goods_model['link_url']
+
+        if "卡奇尔" in goods_name:
+            good = {
+                "goods_id": goods_id,
+                "goods_name": goods_name,
+                "link_url": link_url
+            }
+            # 将 JSON 对象添加到 JSON 数组中
+            goods.append(good)
 except (KeyError, TypeError) as e:
     print(f"Error parse value : {e}")
     list = None
 
-df = pd.DataFrame(list)
+df = pd.DataFrame(goods)
 
 # 将 DataFrame 写入 Excel 文件
-df.to_excel('output.xlsx', index=False, engine='xlsxwriter')
+df.to_excel('output.xlsx', index=False, engine='xlsxwriter')