设置请求头的函数
msg.headers = {
'Host': 'www.jnptzh.net',
'X-Requested-With': 'XMLHttpRequest',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
'Accept': 'text/plain, */*; q=0.01',
'Origin': 'http://www.jnptzh.net',
'Content-Length': '0',
'Connection': 'keep-alive',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.30(0x18001e30) NetType/WIFI Language/zh_TW',
'Referer': 'http://www.jnptzh.net/JnWeiXinWeb/jnBusWeb.jsp',
'Cookie': 'JSESSIONID=47791F4BC976672A28303FE2AE15B973; BMAP_SECKEY=iIGp5DCKUPHx2SOjRsucE_ua0i3b9jR3t6Oj9Wg9OjugEH9al6SAjMACNcLc0EmVsp4fLbczzoMFbe3C6c9GuXcr-aLj_fdTCBDJWlnW_Vor22qygAlcjKFTySGzNz2X3vFKOy3RxJsdjnd4NCUjFZ9eVSRfUPLPN9In8foPdAk; SECKEY_ABVK=X+B4vQ/Jg8ItZSiJGJ2dTyi7nNsArPAHk8Z1Wyazqts%3D'
}
return msg;
数据处理的那个:
var str = msg.payload;
var msg1 = {};
msg1.payload = {};
var str1 = str.replaceAll("<img src='images/mybus.png' class='ui-li-icon ui-corner-none' height='26' width='26' />", "");
str = str1.replaceAll("<span style='font-size:13px;color:red'>", "");
str1 = str.replaceAll("<span style='font-size:13px;color:blue'>", "");
str = str1.replaceAll("</span>", "");
str1 = str.replaceAll("<span style='font-size:18px;color:blue'>", "");
str = str1.replaceAll("<span style='font-size:18px;color:red'>", "");
str1 = str.replaceAll("<li>", "");
str = str1.split("</li>");
msg1.payload = str;
var payload0 = msg1.payload[0];
var payload1 = msg1.payload[1];
var payload2 = msg1.payload[2];
if ((payload0 == "") || (payload0 == null))
msg1.payload[0] = "暂时无法获取";
if ((payload1 == "") || (payload1 == null))
msg1.payload[1] = "暂时无法获取";
if ((payload2 == "") || (payload2 == null))
msg1.payload[2] = "暂时无法获取";
return msg1;
某个请求返回的payload:
"<li><img src='images/mybus.png' class='ui-li-icon ui-corner-none' height='26' width='26' /><span style='font-size:13px;color:red'>苏A00035F</span>距本站<span style='font-size:18px;color:red'>1</span>站<span style='font-size:13px;color:blue'>,约500.00米</span></li><li><img src='images/mybus.png' class='ui-li-icon ui-corner-none' height='26' width='26' /><span style='font-size:13px;color:red'>苏A01919F</span>距本站<span style='font-size:18px;color:red'>7</span>站<span style='font-size:13px;color:blue'>,约3.30公里</span></li><li><img src='images/mybus.png' class='ui-li-icon ui-corner-none' height='26' width='26' /><span style='font-size:13px;color:red'>苏A08871F</span>距本站<span style='font-size:18px;color:red'>8</span>站<span style='font-size:13px;color:blue'>,约4.03公里</span></li>"
|