How does one pull statistics (either daily or over

2019-07-14 08:11发布

问题:

I'm looking through the documentation for the YouTube API and they talk about statistics in their list of things that a user can pull, but I'm at a loss as to how to do the following.

The specific data I need is views per day for a given video. I am happy to pull this one-by-one, or as an entire channel, and either in large chunks of time (with each one saying what date it was viewed on) or day by day, where I'd run a report daily to see what the view count is for that day. However, the only param I see in there relating to this is "time" and when I give it a param of "today" it returns the same global all-time view count for a given video. In any event, time appears to apply only to live video (at least in how it's placed in the doc) so, I'm totally stumped. Maybe there's another doc that I just haven't found that details how one does this exact thing?

All help greatly appreciated.

回答1:

As polynomial said, since the video data isn't constrained by any time periods you should really pull the data every every day if you want day by day statistics.

However, it is possible to retrieve Youtube's video statistics which show historical data (ex: http://sente.cc/misc/yt_video_stats.png) This data isn't available through the API but it can be scraped without too much difficulty.

I didn't have any trouble creating this tool: http://sente.cc/scripts/yt_stats?tcquYYKurJ8



回答2:

The "time" field is used to constrain results formatted as a list, for example comments or live events. You cannot use it to constrain view counts for a video.

You may want to look into retrieving live events for a video to produce the data you want, though it will be constrained to time periods between defined events.