Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib3
- import json
- import time
- def getYoutubeCommentApi(videoId):
- http = urllib3.PoolManager()
- comments=[];
- nextPage="";
- while True:
- r=http.request('POST','http://ytcomments.klostermann.ca/api',body='videoID='+videoId+nextPage)
- json_data = json.loads(r.data)
- if 'nextPageToken' in json_data.keys():
- if json_data['pageToken'] == json_data['nextPageToken']:
- time.sleep(1)
- continue
- else:
- comments=comments+json_data['comments']
- nextPage="&pageToken="+json_data['nextPageToken']
- print("fetch"+nextPage)
- else:
- break
- return comments
- c=getYoutubeCommentApi('XRuKSn3yZZA')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement