我想从 YouTube 视频中获取一些关于“喜欢”、“不喜欢”、“观看”的最小统计信息<强>计数。但是,到目前为止,我可以检索视频信息的 JSON,但没有上述信息。
最佳答案
因此,在不使用 Google API 和执行任何 O-AUTH 的情况下,我只是解析网站并获取点赞计数和标题。
导入请求 导入重新
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")
关于python - 如何从 Youtube 检索喜欢/不喜欢/观看次数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32940484/