Skip to content

Instantly share code, notes, and snippets.

@akkartik
Created November 26, 2011 12:57
Show Gist options
  • Save akkartik/1395622 to your computer and use it in GitHub Desktop.
Save akkartik/1395622 to your computer and use it in GitHub Desktop.
Generate URLs for the pages containing the covers of all editions of Time Magazine
from BeautifulSoup import BeautifulSoup
from urllib2 import urlopen
url = '/time/magazine/current'
while 1:
url='http://www.time.com'+url
soup = BeautifulSoup(urlopen(url))
print url, '--', soup.find('time').renderContents()
url = soup.find(text='Previous Issue').parent['href']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment