瀏覽代碼

add search_url

Ben 6 月之前
父節點
當前提交
e04b598cbf
共有 6 個文件被更改,包括 3266 次插入28 次删除
  1. 二進制
      .DS_Store
  2. 3133 0
      data2.json
  3. 106 24
      main.py
  4. 二進制
      output_卡奇尔.xlsx
  5. 7 0
      parse_params.py
  6. 20 4
      test.py

二進制
.DS_Store


文件差異過大導致無法顯示
+ 3133 - 0
data2.json


文件差異過大導致無法顯示
+ 106 - 24
main.py


二進制
output_卡奇尔.xlsx


文件差異過大導致無法顯示
+ 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')