Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- #-*- coding: utf-8 -*-
- from bs4 import BeautifulSoup
- import urllib.request
- import os, random
- def getRandomXkcdComic():
- resp = urllib.request.urlopen("http://c.xkcd.com/random/comic/")
- soup = BeautifulSoup(resp, from_encoding=resp.info().get_param('charset'))
- for link in soup.find_all('img'):
- if "imgs.xkcd.com/comics" in link['src']:
- comic_image = 'http:' + link['src']
- return comic_image
- random_image = getRandomXkcdComic()
- os.system("wget " + random_image + " -O /home/piotr/.xkcd.png")
- os.system("killall conky")
- os.system("conky -d -c ~/.conky_xkcd")
Add Comment
Please, Sign In to add comment