diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2015-11-07 16:08:12 -0500 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2015-11-07 16:11:36 -0500 |
| commit | f039016ad17cc13a68e7ee96c50168967acabeba (patch) | |
| tree | fd37b8e35b69af69c3179515e9a1fa389a16a0e5 /xkcd.py | |
| parent | 365e75693b6bcf0b8f02e4982943bc5ed3030dd9 (diff) | |
| download | slack-f039016ad17cc13a68e7ee96c50168967acabeba.tar.gz | |
add the xkcd bot
Diffstat (limited to 'xkcd.py')
| -rw-r--r-- | xkcd.py | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -0,0 +1,12 @@ +import requests +import bs4 + +def get_xkcd(comicid): + r = requests.get('http://www.xkcd.org/{0}/'.format(comicid)) + if r.status_code == 200: + soup = bs4.BeautifulSoup(r.content) + img = soup.find("div", {'id':"comic"}).find("img") + return img['title'], img['src'] + +if __name__=="__main__": + print(get_xkcd(1600)) |
