Last active
August 3, 2017 08:30
-
-
Save henull/1823a8c2b381715117caf1de2d216ff0 to your computer and use it in GitHub Desktop.
Dilbert getter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Gets today's Dilbert comic strip, and opens default browser directly to the image. | |
""" | |
import datetime | |
import requests | |
import webbrowser | |
BASEURL = "http://dilbert.com/strip/" | |
DATEPART = datetime.datetime.now().date() | |
URL = BASEURL+str(DATEPART) | |
source_code = requests.get(URL) | |
STRIP_URL = "http://dilbert.com" | |
for line in source_code.content.split('\n'): | |
if "data-image=" in line: | |
items = line.split(' ') | |
for item in items: | |
if 'data-image=' in item: | |
i = item.split('=') | |
STRIP_URL = i[1].strip('"') | |
webbrowser.open(STRIP_URL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment