[
{
"id": "aaaee5847ee47cc2",
"type": "http request",
"z": "56723380.1b6ddc",
"name": "",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://106.14.198.252:8512",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 600,
"y": 800,
"wires": [
[
"96af9a1702ddba60",
"5223ac346e5f7ea4",
"44ba7cb3d730ae71",
"2cd915cc1a4897dd",
"1aae5bfc3267a744",
"9ac1ac60c8f3627f",
"d1e328bca68b19e2",
"ae38606b4ac1fd72"
]
]
},
{
"id": "96af9a1702ddba60",
"type": "html",
"z": "56723380.1b6ddc",
"name": "当前班次-预计时间1",
"property": "payload",
"outproperty": "time1",
"tag": "#app > div.container > div > div:nth-child(4) > div.staTre-timeline-tableBody > div.tableLeft > div.inStation-time",
"ret": "text",
"as": "single",
"x": 820,
"y": 680,
"wires": [
[
"8079ff04d8fc26d8"
]
]
},
{
"id": "5223ac346e5f7ea4",
"type": "html",
"z": "56723380.1b6ddc",
"name": "当前班次-行进方向1",
"property": "payload",
"outproperty": "fangxiang1",
"tag": "#app > div.container > div > div:nth-child(4) > div.staTre-timeline-tableHead > div.tableLeft",
"ret": "text",
"as": "single",
"x": 820,
"y": 640,
"wires": [
[
"8079ff04d8fc26d8"
]
]
},
{
"id": "8079ff04d8fc26d8",
"type": "join",
"z": "56723380.1b6ddc",
"name": "",
"mode": "custom",
"build": "merged",
"property": "",
"propertyType": "full",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "1",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "num",
"reduceFixup": "",
"x": 1030,
"y": 780,
"wires": [
[
"13ee4bd464fc469d"
]
]
},
{
"id": "2cd915cc1a4897dd",
"type": "html",
"z": "56723380.1b6ddc",
"name": "当前班次-预计时间2",
"property": "payload",
"outproperty": "time2",
"tag": "#app > div.container > div > div:nth-child(4) > div.staTre-timeline-tableBody > div.tableRight > div.inStation-time",
"ret": "text",
"as": "single",
"x": 820,
"y": 760,
"wires": [
[
"8079ff04d8fc26d8"
]
]
},
{
"id": "44ba7cb3d730ae71",
"type": "html",
"z": "56723380.1b6ddc",
"name": "当前班次-行进方向2",
"property": "payload",
"outproperty": "fangxiang2",
"tag": "#app > div.container > div > div:nth-child(4) > div.staTre-timeline-tableHead > div.tableRight",
"ret": "text",
"as": "single",
"x": 820,
"y": 720,
"wires": [
[
"8079ff04d8fc26d8"
]
]
},
{
"id": "9ac1ac60c8f3627f",
"type": "html",
"z": "56723380.1b6ddc",
"name": "下一班次-预计时间1",
"property": "payload",
"outproperty": "next_time1",
"tag": "#app > div.container > div > div:nth-child(7) > div.staTre-timeline-tableBody > div.tableLeft > div.inStation-time",
"ret": "text",
"as": "single",
"x": 820,
"y": 860,
"wires": [
[
"8079ff04d8fc26d8"
]
]
},
{
"id": "1aae5bfc3267a744",
"type": "html",
"z": "56723380.1b6ddc",
"name": "下一班次-行进方向1",
"property": "payload",
"outproperty": "next_fangxiang1",
"tag": "#app > div.container > div > div:nth-child(7) > div.staTre-timeline-tableHead > div.tableLeft",
"ret": "text",
"as": "single",
"x": 820,
"y": 820,
"wires": [
[
"8079ff04d8fc26d8"
]
]
},
{
"id": "ae38606b4ac1fd72",
"type": "html",
"z": "56723380.1b6ddc",
"name": "下一班次-预计时间2",
"property": "payload",
"outproperty": "next_time2",
"tag": "#app > div.container > div > div:nth-child(7) > div.staTre-timeline-tableBody > div.tableRight > div.inStation-time",
"ret": "text",
"as": "single",
"x": 820,
"y": 940,
"wires": [
[
"8079ff04d8fc26d8"
]
]
},
{
"id": "d1e328bca68b19e2",
"type": "html",
"z": "56723380.1b6ddc",
"name": "下一班次-行进方向2",
"property": "payload",
"outproperty": "next_fangxiang2",
"tag": "#app > div.container > div > div:nth-child(7) > div.staTre-timeline-tableHead > div.tableRight",
"ret": "text",
"as": "single",
"x": 820,
"y": 900,
"wires": [
[
"8079ff04d8fc26d8"
]
]
},
{
"id": "281f34019a2eb718",
"type": "http request",
"z": "56723380.1b6ddc",
"name": "请求站点信息",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://106.14.198.252:8512/station",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 480,
"y": 720,
"wires": [
[
"dc912886ba410687"
]
]
},
{
"id": "b5dfc9ce023a7d1c",
"type": "inject",
"z": "56723380.1b6ddc",
"name": "每天早上8:11",
"props": [
{
"p": "querySite",
"v": "索山桥西",
"vt": "str"
},
{
"p": "toUser",
"v": "zouxiu",
"vt": "str"
}
],
"repeat": "",
"crontab": "50 07 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 480,
"y": 640,
"wires": [
[
"281f34019a2eb718"
]
]
},
{
"id": "dc912886ba410687",
"type": "function",
"z": "56723380.1b6ddc",
"name": "站点模糊匹配",
"func": "const cheerio = global.get('cheerio');\n\n\n// 使用 cheerio 加载 HTML\nconst $ = cheerio.load(msg.payload);\n\n\n\n// 最终的 JSON 结构\nconst sites = [];\n\n// 遍历每个 .right-con 元素\n$('.right-con').each((index, div) => {\n const stationNames = []; // 存储当前 div 下的所有站名\n\n // 遍历当前 div 下的所有 h4 元素\n $(div).find('h4').each((idx, h4) => {\n // 获取 h4 元素中的文本并添加到列表中\n stationNames.push($(h4).text());\n });\n\n // 如果当前 div 下有站名,则将列表添加到结果中\n if (stationNames.length > 0) {\n sites.push(stationNames);\n }\n});\n\n\n// 创建一个空对象存储 v-line 和文本值\nconst lines = [];\n\n// 遍历所有的 li 元素\n$('body > div > div.left-menu > ul > li').each((index, element) => {\n // 获取当前元素的 v-line 属性\n const vLine = $(element).attr('v-line');\n // 获取当前元素的文本内容,同时去除所有的空白字符(包括空格和换行符)\n const value = $(element).clone().children().remove().end().text().trim();\n lines.push({\n "lineId": vLine,\n "lineName": value\n })\n});\n\nlet queryLine = {}\nlet queryStation = "";\nlet flag = false;\nfor(let i = 0; i < sites.length;i++) {\n for(let j = 0; j < sites[i].length;j++) {\n if (sites[i][j].includes(msg.querySite)) {\n queryLine = lines[i];\n queryStation= sites[i][j];\n flag = true\n break;\n }\n }\n if(flag) {\n break;\n }\n}\n\nlet encodeStation=encodeURIComponent(queryStation)\nlet today = new Date().getDay() == 0 ? 7 : new Date().getDay();\nmsg.headers = { \n 'Cookie': `weekday=${today}; line=${queryLine.lineId}; station=${encodeStation}`\n };\n\nmsg.flag = flag\n// 打印结果对象\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 760,
"wires": [
[
"b766f2408c6d777b"
]
]
},
{
"id": "b766f2408c6d777b",
"type": "switch",
"z": "56723380.1b6ddc",
"name": "查到结果",
"property": "flag",
"propertyType": "msg",
"rules": [
{
"t": "true"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 460,
"y": 800,
"wires": [
[
"aaaee5847ee47cc2"
]
]
}
]