Skip to content

Instantly share code, notes, and snippets.

@hernamesbarbara
Created February 24, 2014 17:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hernamesbarbara/9192320 to your computer and use it in GitHub Desktop.
Save hernamesbarbara/9192320 to your computer and use it in GitHub Desktop.
#!/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