1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); }
function checkDate(dateStr) { y = dateStr.indexOf("年"); m = dateStr.indexOf("月"); d = dateStr.indexOf("日");
month_n = dateStr.substring(y + 1, m);
if (month_n >= 10) return true; return false; }
city = document.getElementById("centerProvinceCity"); day = document.getElementById("testDays"); btn_query = document.getElementById("btnQuerySeat");
cityList = [ "北京", "南京", "苏州", "扬州", "青岛", "上海", "天津", "杭州", "宁波", "温州", ];
for (i = 1; i < city.options.length; ++i) { city.options[i].selected = true; cityName = city.options[i].innerText; if (cityList.indexOf(cityName) === -1) continue; console.log("开始检查城市:" + cityName);
for (j = 1; j < day.options.length; ++j) { if (!checkDate(day.options[j].innerText)) continue; day.options[j].selected = true; btn_query.click();
await sleep(1500); tables = document.getElementsByClassName( "table table-bordered table-striped" ); if (tables.length == 1) { tb = tables[0]; for (row = 2; row < tb.rows.length; ++row) { if (tb.rows[row].cells[3].innerText == "有名额") { console.log( city.options[i].innerText, day.options[j].innerText, tb.rows[row].cells[1].innerText, tb.rows[row].cells[3].innerText ); } } } } }
|