Created
September 8, 2018 07:59
-
-
Save gMan1990/f8cec27ed78bcdef575e6b8a2919d62c to your computer and use it in GitHub Desktop.
杭州驾考初学体验预约筛选
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// URL: http://syjy.5u5u5u5u.com/syjy/reserve/toLessonReservePage_xianxietiyan.htm | |
// 步骤: 一步步拷贝执行 | |
// 1. get map | |
jQuery(function ($) { | |
window._resultMap = {}; | |
$('#areaSwitch>li').each(function (i, v) { | |
var areaId = $(v).attr('areaid'); | |
$.get('http://syjy.5u5u5u5u.com/syjy/reserve/queryExperienceLessonReserveData.htm', { | |
areaId: areaId | |
}, function (data) { | |
$.each(data.data[areaId].busOrgDtoS, function (k1, v1) { | |
$.each(v1.weekDtos, function (k2, v2) { | |
$.each(v2.lessonDtoS, function (k3, v3) { | |
if (v3.remainNum > 0 && v2.date == '2018-09-09') { | |
var quKey = data.data[areaId].name; | |
var quVal = window._resultMap[quKey]; | |
var luKey = v1.address; | |
if (!quVal) { | |
quVal = {}; | |
window._resultMap[quKey] = quVal; | |
quVal[luKey] = []; | |
var luVal = quVal[luKey]; | |
} else { | |
var luVal = quVal[luKey]; | |
if (!luVal) { | |
quVal[luKey] = []; | |
luVal = quVal[luKey]; | |
} | |
} | |
luVal.push({ | |
beginTime: v3.beginTime, | |
endTime: v3.endTime | |
}); | |
} | |
}); | |
}); | |
}); | |
}); | |
}); | |
}); | |
// 2. sort arr | |
jQuery(function ($) { | |
$.each(window._resultMap, function (quKey, quVal) { | |
$.each(quVal, function (luKey, luVal) { | |
luVal.sort(function (a, b) { | |
return a.beginTime > b.beginTime; | |
}); | |
}); | |
}); | |
}); | |
// 3. filter | |
jQuery(function ($) { | |
window._resultArr = []; | |
$.each(window._resultMap, function (quKey, quVal) { | |
$.each(quVal, function (luKey, luVal) { | |
for (var i = 0; i < luVal.length - 1; i++) { | |
if (luVal[i].endTime == luVal[i + 1].beginTime) { | |
window._resultArr.push([luVal[i].beginTime, luVal[i].endTime, luVal[i + 1].endTime, quKey, luKey].join(' ')); | |
} | |
} | |
}); | |
}); | |
}); | |
// 4. output | |
/* _resultArr.sort().join('\n'); */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
暂存,与此gist无太大关系