txkcd.py - scripts - random scripts
HTML git clone https://git.parazyd.org/scripts
DIR Log
DIR Files
DIR Refs
---
txkcd.py (344B)
---
1 #!/usr/bin/env python2
2 #
3 # parazyd - (c) wtfpl
4 # random xkcd comic
5
6 from urllib import urlopen
7 from random import randint
8 from json import load
9
10 latest = load(urlopen("http://www.xkcd.com/info.0.json"))
11 latest = latest['num']
12 num = str(randint(1,latest))
13 xkcd = load(urlopen("http://www.xkcd.com/" + num + "/info.0.json"))
14 print(xkcd['img'])