Browse Source

增加分类文件

cr 4 years ago
parent
commit
4d16130b93
2 changed files with 11 additions and 3 deletions
  1. 9 1
      tools/page-init.js
  2. 2 2
      tools/sku-data.js

+ 9 - 1
tools/page-init.js

@@ -55,7 +55,15 @@ function pageInit(driver) {
55 55
         console.log('sku获取完成')
56 56
 
57 57
         // 保存文件
58
-        saveFile(`/json/${data.title}.json`, JSON.stringify(data, null, 4));
58
+        const configObj = global.configObj;
59
+        let path = configObj.cateName + '/';
60
+        data.cate = configObj.cateName;
61
+        if (configObj.cate2Exist) {
62
+            path += configObj.cate2Name + '/';
63
+            data.cate2 = configObj.cate2Name;
64
+        }
65
+        
66
+        saveFile(`${data.title}.json`, JSON.stringify(data, null, 4), path);
59 67
 
60 68
         // 下载该文件图片
61 69
         downImg(data);

+ 2 - 2
tools/sku-data.js

@@ -65,6 +65,7 @@ function skuData(driver) {
65 65
 
66 66
                         const htmlStr = await driver.getPageSource();
67 67
 
68
+                        console.log('sku', colorIndex, sizeIndex,'总数',colorList.length,sizeList.length);
68 69
                         const d = getSkuData(htmlStr);
69 70
                         if (d) {
70 71
                             sku.push(d);
@@ -72,7 +73,6 @@ function skuData(driver) {
72 73
 
73 74
                         colorIndex++;
74 75
 
75
-                        console.log('colorIndex', colorIndex, colorList.length);
76 76
 
77 77
                         if (colorIndex === colorList.length) {
78 78
                             color.click();
@@ -90,7 +90,7 @@ function skuData(driver) {
90 90
 
91 91
             sizeIndex++;
92 92
 
93
-            console.log('color完毕', sizeIndex, sizeList.length);
93
+            // console.log('color完毕', sizeIndex, sizeList.length);
94 94
 
95 95
             if (sizeIndex === sizeList.length) {
96 96
                 resolve(sku);