Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

增加API数据解析 #784

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jingyuexing
Copy link

无需解析页面,便可直接使用官网提供的API获取到数据,将数据解析称为可以正常识别的数据加以利用,
其解析的方法来自于官网的JS文件:

    function cr(cQ, cS) {
        var cP = [];
        for (var cO = 0; cO < cQ.length; cO++) {
            var cT = [];
            var cN = cQ[cO].split("|");
            cT.secretStr = cN[0];
            cT.buttonTextInfo = cN[1];
            var cR = [];
            cR.train_no = cN[2];
            cR.station_train_code = cN[3];
            cR.start_station_telecode = cN[4];
            cR.end_station_telecode = cN[5];
            cR.from_station_telecode = cN[6];
            cR.to_station_telecode = cN[7];
            cR.start_time = cN[8];
            cR.arrive_time = cN[9];
            cR.lishi = cN[10];
            cR.canWebBuy = cN[11];
            cR.yp_info = cN[12];
            cR.start_train_date = cN[13];
            cR.train_seat_feature = cN[14];
            cR.location_code = cN[15];
            cR.from_station_no = cN[16];
            cR.to_station_no = cN[17];
            cR.is_support_card = cN[18];
            cR.controlled_train_flag = cN[19];
            cR.gg_num = cN[20] ? cN[20] : "--";
            cR.gr_num = cN[21] ? cN[21] : "--";
            cR.qt_num = cN[22] ? cN[22] : "--";
            cR.rw_num = cN[23] ? cN[23] : "--";
            cR.rz_num = cN[24] ? cN[24] : "--";
            cR.tz_num = cN[25] ? cN[25] : "--";
            cR.wz_num = cN[26] ? cN[26] : "--";
            cR.yb_num = cN[27] ? cN[27] : "--";
            cR.yw_num = cN[28] ? cN[28] : "--";
            cR.yz_num = cN[29] ? cN[29] : "--";
            cR.ze_num = cN[30] ? cN[30] : "--";
            cR.zy_num = cN[31] ? cN[31] : "--";
            cR.swz_num = cN[32] ? cN[32] : "--";
            cR.srrb_num = cN[33] ? cN[33] : "--";
            cR.yp_ex = cN[34];
            cR.seat_types = cN[35];
            cR.exchange_train_flag = cN[36];
            cR.houbu_train_flag = cN[37];
            cR.houbu_seat_limit = cN[38];
            if (cN.length > 46) {
                cR.dw_flag = cN[46]
            }
            cR.from_station_name = cS[cN[6]];
            cR.to_station_name = cS[cN[7]];
            cT.queryLeftNewDTO = cR;
            cP.push(cT)
        }
        return cP
    }

因为字符串分割函数Python和JS都是一致的即split(),查找页面当中的split就可以找到,主要看的是是否是用竖线分割即split('|')

@jingyuexing
Copy link
Author

上述引用的代码在官网的queryLeftTikel.js中即可找到

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant