SHOW:
|
|
- or go back to the newest paste.
1 | import urllib2 | |
2 | import json | |
3 | import time | |
4 | import time | |
5 | newjsonobject = {"data":[]} | |
6 | ||
7 | while True: | |
8 | x = urllib2.urlopen("https://www.googleapis.com/youtube/v3/channels?part=statistics&id=UC0v-tlzsn0QZwJnkiaUSJVQ&key={YOUR_KEY_HERE}").read() | |
9 | parsed_json = json.loads(x) | |
10 | x.close() | |
11 | print parsed_json["items"][0]["statistics"]["subscriberCount"] | |
12 | entry = {'Time': int(time.time()), 'SubscriberCount': parsed_json["items"][0]["statistics"]["subscriberCount"]} | |
13 | newjsonobject["data"].append(entry) | |
14 | with open('data.json', 'w') as newjsonfile: | |
15 | json.dump(newjsonobject, newjsonfile) | |
16 | - | time.sleep(2) # Delay for 1 minute (60 seconds) |
16 | + | time.sleep(2) # Delay for 2 seconds |