开发者

Determining the called JSON file in Javascript to use in cURL for data mining - twitter like 'more' button

开发者 https://www.devze.com 2023-03-17 08:34 出处:网络
I\'m trying to extract a stream of historical messages of a site much like twitter. Basically we all know the \'MORE\' button it Twitter. This site has something similar and looks like it grabs a JSON

I'm trying to extract a stream of historical messages of a site much like twitter. Basically we all know the 'MORE' button it Twitter. This site has something similar and looks like it grabs a JSON object and parses it. How can I figure out what/where the JSON object is located so I can use something like CURL to mine the data...

The more JavaScript code is shown here:

more : function () {
    if (!this.max_id)
        return false;
    var c = this;
    if ($("#updates-more .message").length == 0) {
        var b = $("#updates .message:last");
        if (b.length > 0) {
            b = parseInt(b.attr("id").replace("message_", ""), 10);
            if (!isNaN(b))
                this.max_id = b
        }
    }
    var a = {
        stream : this.stream,
        max : this.max_id
    };
    if (this.poll_id)
        a.item_id = this.poll_id;
    this.paused ||
    $("a.pause").trigg开发者_高级运维er("click");
    $("#more-button").hide();
    $("#more-button-loading").show();
    $.getJSON("/streams/poll?" + $.param(a), function (d) {
            $("#more-button-loading").hide();
            if (d.messages) {
                d.more === false ? $("#more-button").hide() : $("#more-button").show();
                var f = [],
                g = [];
                $(d.messages).find("li.message").each(function () {
                        g.push($($(this).outerHtml()));
                        f.push(parseInt($(this).attr("data-ape").replace("messages_", ""), 10))
                    });
                if (g.length > 0) {
                    if (d.max)
                        c.max_id = d.max;
                    g[0].addClass("break");
                    $("#spaceape").trigger("broadcast", {
                            messages : f.join(","),
                            object : {
                                id : a.stream,
                                type : "stream"
                            },
                            verb : "append",
                            type : "messages"
                        });
                    for (d = 0; d < g.length; d++) {
                        g[d].find(".body").stText();
                        g[d].find(".msgDate").stDate();
                        g[d].appendTo("#updates-more")
                    }
                }
            }
        })
}


The line of script you're looking for up there is this:

$.getJSON("/streams/poll?" + $.param(a), function (d) {

That line does the JSON request to the server, and returns a JSON object 'd'. 'd' Contains a list of messages, each with the data I'm guessing you're looking for. This was a bit of an open ended question - is this what you were looking for?

0

精彩评论

暂无评论...
验证码 换一张
取 消