如何从 Youtube 检索喜欢/不喜欢/观看次数? [英] How to retrieve like/dislike/view count from Youtube?

查看:45
本文介绍了如何从 Youtube 检索喜欢/不喜欢/观看次数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 youtube 视频中获取一些关于喜欢"、不喜欢"、观看"的最小统计信息<强>计数.但是,到目前为止,我可以检索视频信息的 JSON,但没有上述信息.

I want to get some minimal statistic Information from a youtube-video for "like", "dislike", "view" count. However, i got so far, that i can retrieve the JSON for the Videoinformation, but there is none of the above mentioned information.

推荐答案

因此,在不使用 Google API 和进行任何 O-AUTH 的情况下,我只是解析网站并获得 like 计数和标题.

So, without using the Google API and and doing any O-AUTH, i am just parsing the website and getting like count and title.

导入请求导入重新

filesInChannel = [
"https://www.youtube.com/watch?v=PYuNBFdwK7k",
"https://www.youtube.com/watch?v=-Ox9MvottBI"
]

def getStats(link):
    page = requests.get(link)
    likes = re.search("with (\d*.\d*.\d*)", page.text).group(1)
    title = re.search("property=\"og:title\" content=\"([^\n]*)", page.text).group(1)
    return (likes, title)


for link in filesInChannel:
    stats = getStats(link)
    print stats[0].encode("utf-8") + " " + stats[1].encode("utf-8")

这篇关于如何从 Youtube 检索喜欢/不喜欢/观看次数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆