可以鬼.py用javascript setInterval重复更新网页?

2024-04-16 19:39:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我打算用鬼.py抓取setInterval每5秒更新一次的网页。你知道吗

我怎样才能通过鬼.py重复,一旦这个脚本有了新的更新?你知道吗

下面的setInterval代码:

(function () {
    var template;
    (function () {
        template = $("#template1 tbody").html();
        GetData();
    })();
    function GetData() {
        var max = 100,
                    sn = $.data(document, "sn");
        if (sn === undefined) {
            sn = 0;
        } else {
            sn = parseInt(sn, 10);
        }
        $.ajax({
            url: path + "ashx/notice.ashx",
            async: true,
            cache: false,
            data: {
                act: "GetBotSignal",
                sn: sn,
                max: max
            },
            type: "get",
            dataType: "json",
            success: function (data) {
                if (data !== null && data.length !== 0) {
                    var html = "";
                    var expselbox = $(".exp-sel-box");
                    for (var i = 0, j = data.length; i < j; i++) {
                        var item = template;
                        item = item.replace(/\{0}/g, data[i].SignalOccurTime);
                        (parseFloat(data[i].Ratio) >= 2 && parseFloat(data[i].Probability) >= 50) ? " sp" : "");
                        html += item;
                    }
                    expselbox.prepend("<tr ef=\"1\" style=\"height:0px;\"></tr>");
                    expselbox.find("tr[ef=1]").animate({ "height": (34 * data.length) + "px" }, "fast", function () {
                        expselbox.find("tr[ef='1']").remove();
                        expselbox.prepend(html);
                        expselbox.find("tr:hidden").fadeIn("fast");
                        expselbox.find("tr:gt(" + max + ")").remove();
                        $.data(document, "sn", data[0].SN);
                        ScrollBar($(".expscall-out"), 642, 342, true);
                    });
                }
            }
        });
    }

    if (srvTime.getHours() > 7 && srvTime.getHours() < 14) {
        setInterval(function () {
            GetData();
        }, 5000);
    }

})();

Tags: dataifvarhtmlfunctiontemplatefinditem