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.
Asked
Active
Viewed 6,581 times
2
-
1Possible duplicate: http://stackoverflow.com/questions/18530618/retrieve-public-statistics-of-video-via-youtube-api – Brandon White Oct 05 '15 at 02:34
-
3Not related to Python at all. – Raptor Oct 05 '15 at 02:34
-
Sorry, i didn't mean to add python as a tag – user1767754 Oct 05 '15 at 03:18
3 Answers
1
So, without using the Google API and and doing any O-AUTH, i am just parsing the website and getting like count and title.
import requests import re
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")

user1767754
- 23,311
- 18
- 141
- 164
-
To add more information, you just have to add more regex search statements – user1767754 Oct 13 '15 at 19:45
-
Given I do not know the video Id, If I want to get views by simply creating search queries, I get a list of options to choose from. Can that window be sorted by Views so that I can filter the highest view? – Rajarshi Bhadra Sep 20 '16 at 15:40
-
how many urls can you scrap with this method? is it possible to use it for thousands of videos? – l3est Dec 17 '20 at 09:56
0
Have you tried videos/getRating
Valid values for this property are:
- dislike
- like
- none
- unspecified
Example:
GET https://www.googleapis.com/youtube/v3/videos/getRating?id=test>&key=<key>

Maxim Belkin
- 138
- 1
- 6

Linda Lawton - DaImTo
- 106,405
- 32
- 180
- 449
-
-
-
@user1767754 they mean an authentication key. you can create one at google developers – InitializeSahib Aug 15 '16 at 01:48
0
The following query using the youtubeAnalytics.reports.query
portion of the YouTube Analytics API v1 will return the count of views, likes, and dislike counts for the channel and time span specified:
GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel=={CHANNEL_ID}&start-date=2018-02-18&end-date=2018-03-26&metrics=views,likes,dislikes&key={YOUR_API_KEY}
Running the query does require the user to be authorized. You can use the APIs Explorer to test and modify the above query.

PoorInRichfield
- 1,436
- 2
- 19
- 29