Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- link_pageToken = 'https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&maxResults=100&pageToken={pageToken}&videoId={videoId}&key={key}'
- key = API_KEY
- videoId = '5ioa36WJmn0'
- comments = []
- link = 'https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&maxResults=100&videoId={videoId}&key={key}'
- r = requests.get(link.format(videoId=videoId, key=key))
- data = r.json()
- while 'nextPageToken' in data:
- link_pageToken = link + "&pageToken={pageToken}"
- r = requests.get(link_pageToken.format(videoId=videoId, key=key, pageToken=data['nextPageToken']))
- data = r.json()
- for i in range(len(data['items'])):
- comments.append(data['items'][i]['snippet']['topLevelComment']['snippet']['textOriginal'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement