Skip to content

Instantly share code, notes, and snippets.

@tankorsmash
Forked from rchrand/xkcd.py
Created February 12, 2013 19:05
Show Gist options
  • Save tankorsmash/4772399 to your computer and use it in GitHub Desktop.
Save tankorsmash/4772399 to your computer and use it in GitHub Desktop.
from bs4 import BeautifulSoup
import requests
import os
images = []
final = ""
r = requests.get('http://xkcd.com/')
soup = BeautifulSoup(r.content)
for imgs in soup.find_all('img'):
images.append(imgs.get('src'))
for text in images:
if "comic" in text:
final = text
os.system("wget " + final)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment