Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import time, sys, email.utils
- # python3-requests
- import requests
- board = (sys.argv[1] if len(sys.argv) > 1 else None) or 'qa'
- now = int(time.time())
- archives = 'https://a.4cdn.org/' + board + '/archive.json'
- thread_placeholder = 'https://a.4cdn.org/' + board + '/thread/{}.json'
- with requests.Session() as s:
- threads = s.get(archives).json()
- print("thread,time_since_archive")
- for thread in threads:
- #print("Testing /" + board + "/" + str(thread), file=sys.stderr)
- thread_url = thread_placeholder.format(thread)
- resp = s.head(thread_url)
- if resp.ok:
- # archival time is identical with last write time, avoiding pulling the whole thread
- archive_time = int(time.mktime(email.utils.parsedate(resp.headers['Last-Modified'])))
- time_since = now - archive_time
- print(thread, time_since, sep=",")
- time.sleep(0.5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement