本文讲解如何在《店铺商品列表监控》流程图的基础上做改进,按照“时间”排序采集商品列表,使之能用于监控多家店铺上新。
改进的地方有两个:
一是在8125这个网页流程中,对标准输入进一步检查,如果设置了”排序“属性的值等于“时间”,那么网页流程就需要在打开店铺网址后,继续点击“时间”这个菜单,使得商品列表按照上架时间的新老关系排序,即新品排在前面,老品排在后面。
Selection_999(243).png

Selection_999(241).png

二是修改流程图的配置内容,令注入的JSON标准输入中包含“排序”=“时间”这一项。
Selection_999(242).png

如果用户需要监控多个店铺,可以设置“店铺链接”这一属性为数组,包含多个店铺网址,如图所示:
Selection_999(246).png
点击“Visual编辑器”检查一下是否填写正确,然后点击“完成”。
Selection_999(247).png

此流程图如下所示:
Selection_999(244).png

流程图导出JSON内容如下所示:

[
    {
        "id": "a375c15371dc7f95",
        "type": "tab",
        "label": "店铺商品列表监控",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "26234a68ce40476e",
        "type": "inject",
        "z": "a375c15371dc7f95",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"店铺链接\":[\"https://shop1k269p2732922.1688.com/page/offerlist.htm\",\"https://leyouwanju.1688.com/page/offerlist.htm\"],\"开始页\":1,\"结束页\":2,\"排序\":\"时间\",\"关闭工作页\":true}",
        "payloadType": "json",
        "x": 150,
        "y": 200,
        "wires": [
            [
                "75c07f1ac09d9c78"
            ]
        ]
    },
    {
        "id": "57f4418fda70bf4b",
        "type": "debug",
        "z": "a375c15371dc7f95",
        "name": "调试 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 630,
        "y": 240,
        "wires": []
    },
    {
        "id": "75c07f1ac09d9c78",
        "type": "dianshangji",
        "z": "a375c15371dc7f95",
        "name": "采集1688店铺商品列表",
        "process": "8125",
        "browser": "",
        "closetab": true,
        "x": 420,
        "y": 220,
        "wires": [
            [
                "57f4418fda70bf4b",
                "ac8a0771a2330832"
            ],
            [
                "57f4418fda70bf4b"
            ],
            [
                "57f4418fda70bf4b"
            ]
        ]
    },
    {
        "id": "ac8a0771a2330832",
        "type": "file",
        "z": "a375c15371dc7f95",
        "name": "",
        "filename": "data/8125_stdout.log",
        "filenameType": "str",
        "appendNewline": true,
        "createDir": true,
        "overwriteFile": "false",
        "encoding": "none",
        "x": 680,
        "y": 140,
        "wires": [
            []
        ]
    }
]

用户可将其复制后再导入到流程管理系统。
cca9a172-e53b-4197-abb8-2cd21d745eb6-image.png

按如下步骤点击运行这套流程,得到右侧调试输出结果,即为按照上新时间排序得到的商品列表。一般而言,只需每天一次采集店铺第1、2页,再与以前的历史记录做对比,即可发现当天上新的商品ID。
Selection_999(245).png