Created
February 24, 2014 17:04
-
-
Save hernamesbarbara/9192320 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
"""excuse.py | |
Usage: | |
excuse.py | |
Arguments: | |
-h --help | |
""" | |
from bs4 import BeautifulSoup | |
import requests | |
import sys | |
from docopt import docopt | |
def main(): | |
try: | |
url = 'http://programmingexcuses.com/' | |
r = requests.get(url) | |
soup = BeautifulSoup(r.content) | |
excuse = soup.find('center') | |
if excuse is not None: | |
excuse = excuse.get_text() | |
sys.stdout.write('\n' + excuse + '\n') | |
else: | |
sys.stderr.write('Something went wrong\n') | |
except: | |
sys.stderr.write('Something went wrong\n') | |
if __name__ == '__main__': | |
args = docopt(__doc__) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jskinner let me tel you'll