Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests as re
- from time import sleep
- from datetime import datetime
- # %%
- # -- Config
- # url: Where the POST request is going to be made
- # REPLACE THE xxx WITH THE VALUE OF https://files.catbox.moe/vztrwo.png
- # It's a regular URL
- url = 'xxx'
- # post_data: Body of the request (basically cookies)
- # REPLACE THE yyy WITH THE VALUE OF https://files.catbox.moe/yj02ac.png
- # It's a large blob of text
- post_data = 'yyy'
- # -- Get session
- session = re.session()
- # %%
- # -- Vars
- waiting = []
- timestamp = []
- n = 0
- # -- Main loop
- # Makes the request 10 -1 times
- while (n := n + 1) < 10:
- r = re.post(url, data=post_data)
- ts = datetime.now()
- data = r.json()
- val = data['actions'][0]['updateViewershipAction']['viewCount']['videoViewCountRenderer']['viewCount']['simpleText']
- val = val.split()
- num = int(val[0].replace(',', ''))
- print(n, num, ts, val[1])
- # This makes it stop when YT no longer reports 'waiting', comment both lines if you don't want that
- if val[1] != 'waiting':
- break
- waiting.append(val)
- timestamp.append(ts.timestamp())
- # Timer of 10 seconds, recommended more than 5
- sleep(10)
Add Comment
Please, Sign In to add comment