Skip to content

Instantly share code, notes, and snippets.

@bdcorps
Created February 17, 2016 04:43
Show Gist options
  • Select an option

  • Save bdcorps/2dc49ce0657cbe7417da to your computer and use it in GitHub Desktop.

Select an option

Save bdcorps/2dc49ce0657cbe7417da to your computer and use it in GitHub Desktop.
import urllib2
from bs4 import BeautifulSoup
import urllib
import os, sys
base = 'https://garfield.com/'
y = input("From what year would you like the comics?")
directory = raw_input ("Where to save?");
if not os.path.exists(directory):
os.makedirs(directory, 0755)
for year in range(y,y+1):
for month in range(1,13):
for day in range(1,32):
if day < 10:
day = '0' + str(day)
if month < 10:
month = '0' + str(month)
url = base + 'uploads/strips/' + str(year) + '-' + str(month) + '-' + str(day) + '.jpg'
print url
urllib.urlretrieve(url,directory+'\\' + str(year) + '-' + str(month) + '-' + str(day) + '.jpg')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment