Advertisement
newb_ie

Untitled

Nov 23rd, 2021
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import requests
  2. import json
  3. link_pageToken = 'https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&maxResults=100&pageToken={pageToken}&videoId={videoId}&key={key}'
  4. key = API_KEY
  5. videoId = '5ioa36WJmn0'
  6. comments = []
  7. link = 'https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&maxResults=100&videoId={videoId}&key={key}'
  8. r = requests.get(link.format(videoId=videoId, key=key))
  9. data = r.json()
  10. while 'nextPageToken' in data:
  11. link_pageToken = link + "&pageToken={pageToken}"
  12. r = requests.get(link_pageToken.format(videoId=videoId, key=key, pageToken=data['nextPageToken']))
  13. data = r.json()
  14. for i in range(len(data['items'])):
  15. comments.append(data['items'][i]['snippet']['topLevelComment']['snippet']['textOriginal'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement