diff options
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)) |
