Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
2.2 kB
3
Indexable
Never
const del = async (mhp, manhom, tc) => {
    url = "https://qldt.ctu.edu.vn/htql/dkmh/student/index.php?action=dky_mhoc";
    let formData = new FormData();
    formData.append("txtMaMonHoc", `~${mhp}`);
    formData.append("hidMaNhom", `~${manhom}`);
    formData.append("hidSoTinChi", `~${tc}`);
    formData.append("cboHocKyMain", "20242");
    formData.append("txtTKB", "");
    formData.append("hidMethod", "delct");
    formData.append("hdKey", "");
    return fetch(url, {
        method: "POST",
        body: formData
    }).then((res) => res.text());
}
const regis = async (mhp, manhom, tc) => {
    url = "https://qldt.ctu.edu.vn/htql/dkmh/student/index.php?action=dky_mhoc";
    let formData = new FormData();
    formData.append("txtMaMonHoc", `${mhp}`);
    formData.append("hidMaNhom", `${manhom}`);
    formData.append("hidSoTinChi", `${tc}`);
    formData.append("cboHocKyMain", "20242");
    formData.append("txtTKB", "1");
    formData.append("hidMethod", "regdetails");
    formData.append("hdKey", "");
    return fetch(url, {
        method: "POST",
        body: formData
    }).then((res) =>{
        return res.text();
    }).then((html) => {
        const parser = new DOMParser();
        const doc = parser.parseFromString(html, 'text/html');
        //return document;
        return [...doc.querySelectorAll("#frmKQDK tr")].map(tr => {
            return {
                id: tr.cells[1]?.innerText,
                gr: tr.cells[3]?.lastElementChild?.value,
            };
        });;
    });
}
const data = [
    {
        id: 'CT182',
        gr: '04',
        tc: '3'
    },
    {
        id: 'TC026',
        gr: '05',
        tc: '1'
    },
    {
        id: 'CT175',
        gr: '08',
        tc: '3'
    },
    {
        id: 'CT179',
        gr: '04',
        tc: '3'
    },
    {
        id: 'ML018',
        gr: '02',
        tc: '2'
    },
    {
        id: 'CT180',
        gr: '11',
        tc: '3'
    },
    {
        id: 'CT178',
        gr: '08',
        tc: '3'
    },
    {
        id: 'CT174',
        gr: '01',
        tc: '3'
    },
]
Promise.all(data.map(item => regis(item.id, item.gr, item.tc))).then((values) => {console.log(values)});
Leave a Comment